38 lines
794 B
Go
38 lines
794 B
Go
package ziface
|
|
|
|
import "net"
|
|
|
|
// IConnection 定义链接的抽象层
|
|
type IConnection interface {
|
|
|
|
// Start 启动链接
|
|
Start()
|
|
|
|
// Stop 关闭连接
|
|
Stop()
|
|
|
|
// GetTcpConnection 获取当前链接绑定的socket
|
|
GetTcpConnection() *net.TCPConn
|
|
|
|
// GetConnectionID 获取当前链接模块的ID
|
|
GetConnectionID() uint32
|
|
|
|
// RemoteAddr 获取远程客户点的tcp 状态 ip port
|
|
RemoteAddr() net.Addr
|
|
|
|
// SendMsg 发送数据,将数据发送给远程客户端
|
|
SendMsg(msgId uint32, data []byte) error
|
|
|
|
//设置连接属性
|
|
SetProperty(key string, value interface{})
|
|
|
|
//获取连接属性
|
|
GetProperty(key string) (interface{}, error)
|
|
|
|
//移除连接属性
|
|
RemoveProperty(key string)
|
|
}
|
|
|
|
// 定义一个处理链接的方法
|
|
type HandleFunc func(*net.TCPConn, []byte, int) error
|