Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExist ¶
func IsClientClosed ¶
func IsClientNotExist ¶
func SetMessageReader ¶
func SetMessageReader(s MessageReader)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represent a user conn client.
func NewClient ¶
func NewClient(conn conn.Connection, mgr gate.Gateway, handler gate.MessageHandler) *Client
func NewClientWithConfig ¶ added in v1.2.4
func NewClientWithConfig(conn conn.Connection, mgr gate.Gateway, handler gate.MessageHandler, config *ClientConfig) *Client
func (*Client) EnqueueMessage ¶
func (c *Client) EnqueueMessage(msg *messages.GlideMessage) error
EnqueueMessage enqueue message to client message queue.
func (*Client) Exit ¶
func (c *Client) Exit()
Exit client, note: exit client will not close conn right now, but will close when message chan is empty. It's close read right now, and close write when all message in queue is sent.
type ClientConfig ¶ added in v1.2.4
type ClientConfig struct { // ClientHeartbeatDuration is the duration of heartbeat. ClientHeartbeatDuration time.Duration // ServerHeartbeatDuration is the duration of server heartbeat. ServerHeartbeatDuration time.Duration // HeartbeatLostLimit is the max lost heartbeat count. HeartbeatLostLimit int // CloseImmediately true express when client exit, discard all message in queue, and close connection immediately, // otherwise client will close read, and mark as stateClosing, the client cannot receive and enqueue message, // after all message in queue is sent, client will close write and connection. CloseImmediately bool }
ClientConfig client config
type Impl ¶
func (*Impl) EnqueueMessage ¶
EnqueueMessage to the client with the specified id.
func (*Impl) ExitClient ¶
ExitClient close the client with the specified id. If the client is not exist, return errClientNotExist.
type MessageReader ¶
type MessageReader interface { // Read 阻塞读取, 会阻塞当前协程 Read(conn conn.Connection) (*messages.GlideMessage, error) // ReadCh 返回两个管道, 第一个用于读取内容, 第二个用于发送停止读取, 停止读取时切记要发送停止信号 ReadCh(conn conn.Connection) (<-chan *readerRes, chan<- interface{}) }
MessageReader 表示一个从连接中(Connection)读取消息的读取者, 可以用于定义如何从连接中读取并解析消息.
Click to show internal directories.
Click to hide internal directories.