wsKit

package
v2.8.133 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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 DefaultUpgrader

func DefaultUpgrader() *websocket.Upgrader

DefaultUpgrader 默认的Upgrader.

@return 并发安全的

func PolyfillWebSocketRequest

func PolyfillWebSocketRequest(r *http.Request)

PolyfillWebSocketRequest

此函数是为了避免情况: 代理(e.g.Nginx)没有设置WebSocket穿透,导致WebSocket服务收到的WebSocket请求的header有问题.

Types

type WsChannel

type WsChannel struct {
	pushKit.BaseChannel
	// contains filtered or unexported fields
}

func (*WsChannel) BindBsid added in v2.8.128

func (channel *WsChannel) BindBsid(bsid string)

func (*WsChannel) BindGroup added in v2.8.128

func (channel *WsChannel) BindGroup(group string)

func (*WsChannel) BindUser added in v2.8.128

func (channel *WsChannel) BindUser(user string)

func (*WsChannel) Close

func (channel *WsChannel) Close(reason string) (err error)

Close 后端主动关闭通道.

func (*WsChannel) Dispose added in v2.8.132

func (channel *WsChannel) Dispose()

func (*WsChannel) Initialize added in v2.8.132

func (channel *WsChannel) Initialize() (err error)

func (*WsChannel) Push

func (channel *WsChannel) Push(data []byte) error

func (*WsChannel) PushMessage

func (channel *WsChannel) PushMessage(messageType messageType, data []byte) (err error)

PushMessage 推送消息给客户端.

@param messageType MessageTypeText || MessageTypeBinary

type WsProcessor

type WsProcessor struct {
	pushKit.Processor
	// 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) Process added in v2.8.128

func (p *WsProcessor) Process(w http.ResponseWriter, r *http.Request)

func (*WsProcessor) ProcessWithGin added in v2.8.128

func (p *WsProcessor) ProcessWithGin(ctx *gin.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL