Documentation ¶
Index ¶
- Variables
- type PackageHandler
- type Protocol
- type SClient
- type TcpClient
- func (c *TcpClient) Close()
- func (c *TcpClient) Connect() <-chan bool
- func (c *TcpClient) Error() <-chan *socket.Error
- func (c *TcpClient) Msg() <-chan []byte
- func (c *TcpClient) SetLogger(lg logs.Logger)
- func (c *TcpClient) SetReConn(reconn bool, reConnectTime time.Duration)
- func (c *TcpClient) Write(data []byte)
- type TcpMsg
- type TcpServer
Constants ¶
This section is empty.
Variables ¶
View Source
var ClientDoneCallBackFun func(clientID string)
客户端断开回调函数
View Source
var NewClientCallBackFun func(client *SClient)
新连接回调函数
Functions ¶
This section is empty.
Types ¶
type PackageHandler ¶
数据打包处理器
type Protocol ¶
type Protocol struct { Handler PackageHandler //数据编码handler // contains filtered or unexported fields }
Protocol 自定义协议 解决TCP粘包问题
func NewProtocol ¶
NewProtocol 初始化一个Protocol chanLength为解析成功数据channel缓冲长度
func (*Protocol) SetHeartBeat ¶
设置心跳包数据内容,如果接收到的一条消息刚好于设置的心跳包 内容一致,这条消息将会忽略不会进入读取成功的消息队列中
type SClient ¶
type SClient struct { IsClose <-chan struct{} //关闭channel ID string //客户端唯一标示 // contains filtered or unexported fields }
TCP连接到服务器的客户端
type TcpClient ¶
type TcpClient struct { IsClose <-chan struct{} //关闭channel // contains filtered or unexported fields }
func NewTcpClient ¶
新客户端对象,注意输出channel error 否则错误阻塞可能会到这无法正常运行
type TcpServer ¶
type TcpServer struct { IsClose <-chan struct{} //关闭channel // contains filtered or unexported fields }
TCP服务器对象
func NewTcpServer ¶
新建一个服务端,port为监听端口 注意处理channel error 否则程序阻塞无法正常运行
Click to show internal directories.
Click to hide internal directories.