Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { ID() uint64 Local() string Close() Send(msg server.Message) error Recv() (server.Message, error) }
客户端抽象定义
type ClientContext ¶
type ClientContext struct { MessageProtocol server.MessageProtocol CB *Callback TCPConnectionConfig *TCPConnectionConfig UDPConnectionConfig *UDPConnectionConfig }
客户端上下文
type OrigUDPConnection ¶ added in v0.0.2
UDP原始连接的简单封装
func (*OrigUDPConnection) Close ¶ added in v0.0.2
func (ouc *OrigUDPConnection) Close() error
func (*OrigUDPConnection) ReadFromUDP ¶ added in v0.0.2
func (ouc *OrigUDPConnection) ReadFromUDP() ([]byte, *net.UDPAddr, error)
func (*OrigUDPConnection) SendToUDP ¶ added in v0.0.2
func (ouc *OrigUDPConnection) SendToUDP(addr *net.UDPAddr, bs []byte) error
func (*OrigUDPConnection) TryGetConnID ¶ added in v0.0.2
func (oc *OrigUDPConnection) TryGetConnID(remote *net.UDPAddr, timeout time.Duration) (uint64, error)
尝试发送消息获取逻辑连接的ID
type TCPAsyncClient ¶
type TCPAsyncClient struct {
// contains filtered or unexported fields
}
客户端的TCP异步实现
func DialTCPAsyncClient ¶
func DialTCPAsyncClient(address string, ctx *ClientContext, id uint64) (*TCPAsyncClient, error)
构造客户端并连接远程服务 将启动两个goroutine进行消息收发
func (*TCPAsyncClient) Close ¶
func (c *TCPAsyncClient) Close()
func (*TCPAsyncClient) ID ¶
func (c *TCPAsyncClient) ID() uint64
func (*TCPAsyncClient) Local ¶
func (c *TCPAsyncClient) Local() string
func (*TCPAsyncClient) Recv ¶
func (c *TCPAsyncClient) Recv() (server.Message, error)
异步接收消息. 从消息缓冲区中读一个消息, 缓冲区空时立刻返回返回nil
func (*TCPAsyncClient) RecvChan ¶
func (c *TCPAsyncClient) RecvChan() <-chan server.Message
直接使用接收消息缓冲队列
type TCPConnectionConfig ¶ added in v0.0.2
type TCPConnectionConfig struct {
*server.TCPConnectionConfig
}
type TCPSyncClient ¶
type TCPSyncClient struct {
// contains filtered or unexported fields
}
客户端的TCP同步型
func DialTCPSyncClient ¶
func DialTCPSyncClient(address string, ctx *ClientContext, id uint64) (*TCPSyncClient, error)
构造客户端并连接远程服务
func (*TCPSyncClient) Close ¶
func (c *TCPSyncClient) Close()
func (*TCPSyncClient) ID ¶
func (c *TCPSyncClient) ID() uint64
func (*TCPSyncClient) Local ¶
func (c *TCPSyncClient) Local() string
type UDPAsyncClient ¶ added in v0.0.2
type UDPAsyncClient struct {
// contains filtered or unexported fields
}
客户端的UDP异步实现
func DialUDPAsyncClient ¶ added in v0.0.2
func DialUDPAsyncClient(address string, ctx *ClientContext) (*UDPAsyncClient, error)
构造客户端并连接远程服务 将启动两个goroutine进行消息收发, 以及一个读取udp分片消息的goroutine
func (*UDPAsyncClient) Close ¶ added in v0.0.2
func (c *UDPAsyncClient) Close()
func (*UDPAsyncClient) ID ¶ added in v0.0.2
func (c *UDPAsyncClient) ID() uint64
func (*UDPAsyncClient) Local ¶ added in v0.0.2
func (c *UDPAsyncClient) Local() string
func (*UDPAsyncClient) Recv ¶ added in v0.0.2
func (c *UDPAsyncClient) Recv() (server.Message, error)
异步接收消息. 从消息缓冲区中读一个消息, 缓冲区空时立刻返回返回nil
func (*UDPAsyncClient) RecvChan ¶ added in v0.0.2
func (c *UDPAsyncClient) RecvChan() <-chan server.Message
直接使用接收消息缓冲队列
type UDPConnectionConfig ¶ added in v0.0.2
type UDPConnectionConfig struct { *server.UDPConnectionConfig TimeoutDialMS int }
UDP连接配置
type UDPSyncClient ¶ added in v0.0.2
type UDPSyncClient struct {
// contains filtered or unexported fields
}
客户端的UDP同步型
func DialUDPSyncClient ¶ added in v0.0.2
func DialUDPSyncClient(address string, ctx *ClientContext) (*UDPSyncClient, error)
构造客户端并连接远程服务 其中包含一个用于读取udp分片消息的goroutine
func (*UDPSyncClient) Close ¶ added in v0.0.2
func (c *UDPSyncClient) Close()
func (*UDPSyncClient) ID ¶ added in v0.0.2
func (c *UDPSyncClient) ID() uint64
func (*UDPSyncClient) Local ¶ added in v0.0.2
func (c *UDPSyncClient) Local() string
Click to show internal directories.
Click to hide internal directories.