Documentation ¶
Index ¶
- Constants
- type BaseTextMessageController
- type Client
- type ClientManager
- type Config
- type ReceiveMessage
- type RedisPubSub
- type State
- type TextMessageController
- type WebSocket
- func (ws *WebSocket) GetClientManager() *ClientManager
- func (ws *WebSocket) Handle(ctx context.Context, path string, r *http.Request, w http.ResponseWriter)
- func (ws *WebSocket) OnTextMessageController(scene string, controller TextMessageController)
- func (ws *WebSocket) SetAuthorizationFunc(...)
- func (ws *WebSocket) SetBeforeFunc(...)
- func (ws *WebSocket) SetClientCloseFunc(f func(context.Context, string))
Constants ¶
View Source
const (
ConnUUIDCTXKey = "WebSocketConnUUIDCTXKey"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseTextMessageController ¶
type BaseTextMessageController struct { Client *Client Action string ActionParams map[string]interface{} }
func (*BaseTextMessageController) Init ¶
func (b *BaseTextMessageController) Init(_ TextMessageController)
func (*BaseTextMessageController) ParsePayload ¶
func (b *BaseTextMessageController) ParsePayload(_ context.Context, client *Client, message ReceiveMessage) (err error)
type Client ¶
type ClientManager ¶
type ClientManager struct {
// contains filtered or unexported fields
}
func NewClientManager ¶
func NewClientManager() *ClientManager
func (*ClientManager) Delete ¶
func (m *ClientManager) Delete(uuid string)
func (*ClientManager) IsExist ¶
func (m *ClientManager) IsExist(uuid string) bool
func (*ClientManager) Len ¶
func (m *ClientManager) Len() int
func (*ClientManager) Range ¶
func (m *ClientManager) Range(f func(key, value any) bool)
func (*ClientManager) Store ¶
func (m *ClientManager) Store(uuid string, c *Client)
type Config ¶
type Config struct { HandshakeTimeoutSec time.Duration `json:"handshakeTimeoutSec"` ReadBufferSize int `json:"readBufferSize"` WriteBufferSize int `json:"writeBufferSize"` WriteBufferPool int `json:"writeBufferPool"` AllowedOrigins []string `json:"allowedOrigins"` EnableCompression bool `json:"enableCompression"` }
type ReceiveMessage ¶
type ReceiveMessage struct { SID string `json:"sid"` Scene string `json:"scene"` SceneParams map[string]interface{} `json:"sceneParams"` Action string `json:"action"` ActionParams map[string]interface{} `json:"actionParams"` }
{ "sid": "xxxxxxxxxxxxxx", "scene": "test", "sceneParams": { "key1": 1234, "key2": "value" }, "action": "test", "actionParams": { "key1": 1234, "key2": "value" } }
type RedisPubSub ¶
type RedisPubSub struct {
// contains filtered or unexported fields
}
func NewRedisPubSub ¶
func NewRedisPubSub(channels ...string) *RedisPubSub
type TextMessageController ¶
type TextMessageController interface { Init(base TextMessageController) ParsePayload(ctx context.Context, c *Client, message ReceiveMessage) error Process(ctx context.Context) error }
type WebSocket ¶
type WebSocket struct {
// contains filtered or unexported fields
}
func (*WebSocket) GetClientManager ¶
func (ws *WebSocket) GetClientManager() *ClientManager
func (*WebSocket) OnTextMessageController ¶
func (ws *WebSocket) OnTextMessageController(scene string, controller TextMessageController)
func (*WebSocket) SetAuthorizationFunc ¶
func (*WebSocket) SetBeforeFunc ¶ added in v0.1.7
Click to show internal directories.
Click to hide internal directories.