Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Method ¶
type Method string
Method of ws
const ( // MethodPing ping MethodPing Method = "Ping" // MethodResponse response MethodResponse Method = "Response" // MethodSubscribe 消息订阅 MethodSubscribe Method = "Subscribe" // MethodUnsubscribe 取消订阅 MethodUnsubscribe Method = "Unsubscribe" // MethodBroadcast 广播 MethodBroadcast Method = "Broadcast" // MethodDisconnect 断开连接 MethodDisconnect Method = "Disconnect" )
type Options ¶
type Options struct { Auth func(c *hfwctx.Context) error // WebSocket 认证 Buffer int // 缓冲区间。default: 16 Timeout time.Duration // 超时时间。default: 3s Heartbeat time.Duration // 心跳。default: 5s Action func(c *hfwctx.Context, session *Session) // 主动推送 }
Options .
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session .
func (*Session) WriteError ¶
WriteError WebSocket 返回错误
func (*Session) WriteResponse ¶
func (sess *Session) WriteResponse(data interface{})
WriteResponse 手动推送 response 至 WebSocket
type WebSocketBroadcast ¶
type WebSocketBroadcast struct { Subject subject `json:"subject" validate:"required"` Time string `json:"time" validate:"required"` Data interface{} `json:"data" validate:"required"` }
WebSocketBroadcast .
type WebSocketRequest ¶
type WebSocketRequest struct { ID hfwctx.ID `json:"id" validate:"required"` Method Method `json:"method" validate:"required"` Params *json.RawMessage `json:"params,omitempty"` }
WebSocketRequest .
Click to show internal directories.
Click to hide internal directories.