Documentation ¶
Index ¶
Constants ¶
View Source
const ( MessageTypeText messageType = websocket.TextMessage MessageTypeBinary messageType = websocket.BinaryMessage )
Variables ¶
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) PushMessage ¶
PushMessage 推送消息给客户端.
@param messageType MessageTypeText || MessageTypeBinary
type WsProcessor ¶
type WsProcessor struct {
// contains filtered or unexported fields
}
func NewProcessor ¶
func NewProcessor(upgrader *websocket.Upgrader, idGenerator func() (string, error), listener pushKit.Listener, messageType messageType) (*WsProcessor, error)
NewProcessor
@param upgrader 可以为nil @param idGenerator 可以为nil(使用xid) @param listener 不能为nil
func (*WsProcessor) Handle ¶
func (p *WsProcessor) Handle(w http.ResponseWriter, r *http.Request)
func (*WsProcessor) HandleWithGin ¶
func (p *WsProcessor) HandleWithGin(ctx *gin.Context)
Click to show internal directories.
Click to hide internal directories.