You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
900 B
34 lines
900 B
package ziface
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
//定义连接接口
|
|
type IConnection interface {
|
|
//启动连接,让当前连接开始工作
|
|
Start()
|
|
//停止连接,结束当前连接状态M
|
|
Stop()
|
|
//返回ctx,用于用户自定义的go程获取连接退出状态
|
|
Context() context.Context
|
|
//从当前连接获取原始的socket TCPConn
|
|
GetTCPConnection() *net.TCPConn
|
|
//获取当前连接ID
|
|
GetConnID() uint32
|
|
//获取远程客户端地址信息
|
|
RemoteAddr() net.Addr
|
|
|
|
//直接将Message数据发送数据给远程的TCP客户端(无缓冲)
|
|
SendMsg(msgID uint32, data []byte) error
|
|
//直接将Message数据发送给远程的TCP客户端(有缓冲)
|
|
SendBuffMsg(msgID uint32, data []byte) error
|
|
|
|
//设置链接属性
|
|
SetProperty(key string, value interface{})
|
|
//获取链接属性
|
|
GetProperty(key string) (interface{}, error)
|
|
//移除链接属性
|
|
RemoveProperty(key string)
|
|
}
|