Documentation ¶
Index ¶
- Variables
- func DefaultUpgrader() *websocket.Upgrader
- func PolyfillWebSocketRequest(r *http.Request)
- type WsChannel
- func (channel *WsChannel) BindBsid(bsid string)
- func (channel *WsChannel) BindGroup(group string)
- func (channel *WsChannel) BindUser(user string)
- func (channel *WsChannel) Close(reason string) (err error)
- func (channel *WsChannel) Dispose()
- func (channel *WsChannel) Initialize() error
- func (channel *WsChannel) Push(data []byte) error
- func (channel *WsChannel) PushMessage(messageType messageType, data []byte) (err error)
- type WsProcessor
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MessageTypeText = messageType{ // contains filtered or unexported fields } MessageTypeBinary = messageType{ // contains filtered or unexported fields } )
View Source
var IsWebSocketUpgrade func(r *http.Request) bool = websocket.IsWebSocketUpgrade
IsWebSocketUpgrade 是否是WebSocket请求?
Functions ¶
func PolyfillWebSocketRequest ¶
PolyfillWebSocketRequest
此函数是为了避免情况: 代理(e.g.Nginx)没有设置WebSocket穿透,导致WebSocket服务收到的WebSocket请求的header有问题.
Types ¶
type WsChannel ¶
type WsChannel struct { pushKit.BaseChannel // contains filtered or unexported fields }
func (*WsChannel) Dispose ¶
func (channel *WsChannel) Dispose()
Dispose 仅是释放资源,不会关闭通道(应当先关闭通道,再释放资源).
func (*WsChannel) Initialize ¶
func (*WsChannel) PushMessage ¶
PushMessage 推送消息给客户端.
@param messageType MessageTypeText || MessageTypeBinary
type WsProcessor ¶
func NewProcessor ¶
func NewProcessor(upgrader *websocket.Upgrader, idGenerator func() (string, error), listener pushKit.Listener, messageType messageType) (*WsProcessor, error)
NewProcessor
!!!: 需要先调用 pushKit.MustSetUp 或 pushKit.SetUp.
@param upgrader 可以为nil(将使用默认的) @param idGenerator 可以为nil(将使用xid) @param listener 不能为nil
func (*WsProcessor) Process ¶
func (p *WsProcessor) Process(w http.ResponseWriter, r *http.Request)
func (*WsProcessor) ProcessWithGin ¶
func (p *WsProcessor) ProcessWithGin(ctx *gin.Context)
Click to show internal directories.
Click to hide internal directories.