Documentation ¶
Index ¶
- Constants
- func WebSocketMonitor(m *Manager) (err error)
- type BaseTextMessageController
- type Client
- func (c *Client) Close()
- func (c *Client) DebugLog(action string, messageType int, message []byte, err error, ...)
- func (c *Client) ErrorLog(action string, messageType int, message []byte, err error, ...)
- func (c *Client) InfoLog(action string, messageType int, message []byte, err error, ...)
- func (c *Client) ReadMessage() (messageType int, message []byte, err error)
- func (c *Client) WarnLog(action string, messageType int, message []byte, err error, ...)
- func (c *Client) WriteTextMessage(message []byte) (err error)
- type Manager
- type ReceiveMessage
- type State
- type Task
- type TextMessageController
- type WebSocketRouter
- func (r *WebSocketRouter) AddMiddleware(m gin.HandlerFunc)
- func (r *WebSocketRouter) AddTask(t Task)
- func (r *WebSocketRouter) GetTasks() []func(context.Context) func() error
- func (r *WebSocketRouter) GetTextMessageController(scene string) (controller TextMessageController, err error)
- func (r *WebSocketRouter) OnTextMessageController(scene string, controller TextMessageController)
- func (r *WebSocketRouter) RegisterHandler(s *server.Server)
- func (r *WebSocketRouter) SetAuthorization(f func(ctx *gin.Context) bool)
- func (r *WebSocketRouter) SetClientCloseFunc(f func(uuidStr string))
Constants ¶
View Source
const WebSocketConnUUIDCTXKey = "WebSocketConnUUIDCTXKey"
Variables ¶
This section is empty.
Functions ¶
func WebSocketMonitor ¶
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(client *Client, message ReceiveMessage) (err error)
type Client ¶
type Client struct { Ctx *gin.Context Conn *websocket.Conn // 客户端状态信息 State State Logger *logit.Helper // contains filtered or unexported fields }
func (*Client) ReadMessage ¶
func (*Client) WriteTextMessage ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
type ReceiveMessage ¶
type ReceiveMessage struct { Scene string `json:"scene"` SceneParams map[string]interface{} `json:"sceneParams"` Action string `json:"action"` ActionParams map[string]interface{} `json:"actionParams"` }
{ "scene": "test", "sceneParams": { "key1": 1234, "key2": "value" }, "action": "test", "actionParams": { "key1": 1234, "key2": "value" } }
type TextMessageController ¶
type TextMessageController interface { Init(base TextMessageController) ParsePayload(c *Client, message ReceiveMessage) error Process() error }
type WebSocketRouter ¶
type WebSocketRouter struct { ClientManager *Manager // contains filtered or unexported fields }
func NewWebSocketRouter ¶
func NewWebSocketRouter(path string) *WebSocketRouter
func (*WebSocketRouter) AddMiddleware ¶
func (r *WebSocketRouter) AddMiddleware(m gin.HandlerFunc)
func (*WebSocketRouter) AddTask ¶
func (r *WebSocketRouter) AddTask(t Task)
func (*WebSocketRouter) GetTasks ¶
func (r *WebSocketRouter) GetTasks() []func(context.Context) func() error
func (*WebSocketRouter) GetTextMessageController ¶
func (r *WebSocketRouter) GetTextMessageController(scene string) (controller TextMessageController, err error)
func (*WebSocketRouter) OnTextMessageController ¶
func (r *WebSocketRouter) OnTextMessageController(scene string, controller TextMessageController)
func (*WebSocketRouter) RegisterHandler ¶
func (r *WebSocketRouter) RegisterHandler(s *server.Server)
func (*WebSocketRouter) SetAuthorization ¶
func (r *WebSocketRouter) SetAuthorization(f func(ctx *gin.Context) bool)
func (*WebSocketRouter) SetClientCloseFunc ¶
func (r *WebSocketRouter) SetClientCloseFunc(f func(uuidStr string))
Click to show internal directories.
Click to hide internal directories.