Documentation ¶
Index ¶
- Variables
- func IsSseSupported(w http.ResponseWriter, r *http.Request) error
- func NewProcessor(idGenerator func() (string, error), listener pushKit.Listener, ...) (pushKit.Processor, error)
- func SetHeaders(w http.ResponseWriter)
- type Event
- type MessageEventdeprecated
- type SseChannel
- func (channel *SseChannel) BindBsid(bsid string)
- func (channel *SseChannel) BindGroup(group string)
- func (channel *SseChannel) BindUser(user string)
- func (channel *SseChannel) Close(reason string) error
- func (channel *SseChannel) Dispose()
- func (channel *SseChannel) Initialize() error
- func (channel *SseChannel) Push(data []byte) error
- func (channel *SseChannel) PushMessage(msgType messageType, data []byte) (err error)
- type SseProcessor
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // MessageTypeRaw 对于data,不做任何处理 MessageTypeRaw = messageType{ "raw", } // MessageTypeEncode 对于data,编码一下(前端需对应处理) MessageTypeEncode = messageType{ "encode", } // MessageTypeBase64 对于data,base64编码一下(前端需对应处理) MessageTypeBase64 = messageType{ "base64", } )
Functions ¶
func IsSseSupported ¶
func IsSseSupported(w http.ResponseWriter, r *http.Request) error
IsSseSupported
@return 为"": 支持SSE
Types ¶
type MessageEvent
deprecated
type MessageEvent struct { // Id /* PS: (1) 对应前端的 e.lastEventId. (2) 可以为"". */ Id string // Event /* PS: (1) 对应前端的 e.type. (2) 可以为""(此时等价于"message") (3) 如果不是 "message" 的话,前端需要自行添加对应的监听. */ Event string // Data /* PS: (1) 对应前端的 e.data. (2) 可以为"". (3) 建议对内容编码下,以防其中有特殊字符(\n等). */ Data string }
MessageEvent 定义SSE事件.
Deprecated: Use sse.Event of github.com/gin-contrib/sse instead.
type SseChannel ¶
type SseChannel struct { pushKit.BaseChannel // contains filtered or unexported fields }
func (*SseChannel) BindBsid ¶
func (channel *SseChannel) BindBsid(bsid string)
func (*SseChannel) BindGroup ¶
func (channel *SseChannel) BindGroup(group string)
func (*SseChannel) BindUser ¶
func (channel *SseChannel) BindUser(user string)
func (*SseChannel) Close ¶
func (channel *SseChannel) Close(reason string) error
Close (写锁)后端主动关闭通道.
func (*SseChannel) Dispose ¶
func (channel *SseChannel) Dispose()
Dispose 仅是释放资源,不会关闭通道(应当先关闭通道,再释放资源).
func (*SseChannel) Initialize ¶
func (channel *SseChannel) Initialize() error
func (*SseChannel) PushMessage ¶
func (channel *SseChannel) PushMessage(msgType messageType, data []byte) (err error)
PushMessage (写锁)推送消息给客户端.
type SseProcessor ¶
func (*SseProcessor) Process ¶
func (p *SseProcessor) Process(w http.ResponseWriter, r *http.Request)
func (*SseProcessor) ProcessWithGin ¶
func (p *SseProcessor) ProcessWithGin(ctx *gin.Context)
Click to show internal directories.
Click to hide internal directories.