Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Dial 拨号连接 Dial() (Conn, error) // OnConnect 监听连接打开 OnConnect(handler ConnectHandler) // OnReceive 监听接收消息 OnReceive(handler ReceiveHandler) // OnDisconnect 监听连接断开 OnDisconnect(handler DisconnectHandler) }
type CloseHandler ¶
type CloseHandler func()
type Conn ¶
type Conn interface { // ID 获取连接ID ID() int64 // UID 获取用户ID UID() int64 // Bind 绑定用户ID Bind(uid int64) // Unbind 解绑用户ID Unbind() // Send 发送消息(同步) Send(msg []byte, msgType ...int) error // Push 发送消息(异步) Push(msg []byte, msgType ...int) error // State 获取连接状态 State() ConnState // Close 关闭连接 Close(isForce ...bool) error // LocalIP 获取本地IP LocalIP() (string, error) // LocalAddr 获取本地地址 LocalAddr() (net.Addr, error) // RemoteIP 获取远端IP RemoteIP() (string, error) // RemoteAddr 获取远端地址 RemoteAddr() (net.Addr, error) }
type ConnectHandler ¶
type ConnectHandler func(conn Conn)
type DisconnectHandler ¶
type DisconnectHandler func(conn Conn)
type ReceiveHandler ¶
type Server ¶
type Server interface { // Addr 监听地址 Addr() string // Start 启动服务器 Start() error // Stop 关闭服务器 Stop() error // Protocol 协议 Protocol() string // OnStart 监听服务器启动 OnStart(handler StartHandler) // OnStop 监听服务器关闭 OnStop(handler CloseHandler) // OnConnect 监听连接打开 OnConnect(handler ConnectHandler) // OnReceive 监听接收消息 OnReceive(handler ReceiveHandler) // OnDisconnect 监听连接断开 OnDisconnect(handler DisconnectHandler) }
type StartHandler ¶
type StartHandler func()
Click to show internal directories.
Click to hide internal directories.