28 lines
769 B
Go
28 lines
769 B
Go
package ziface
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
type IConnection interface {
|
|
// Start 启动连接
|
|
Start()
|
|
// Stop 停止连接
|
|
Stop()
|
|
// GetTCPConnection 获取当前连接的 TCP Socket 套接字
|
|
GetTCPConnection() *net.TCPConn
|
|
// GetConnID 获取当前连接 ID
|
|
GetConnID() uint32
|
|
// RemoteAddr 获取远程客户端地址信息
|
|
RemoteAddr() net.Addr
|
|
// SendMsg 发送数据,将数据发送给远程的客户端(无缓冲)
|
|
SendMsg(msgID uint32, data []byte) error
|
|
// SendBuffMsg 发送数据,将数据发送给远程的客户端(有缓冲)
|
|
SendBuffMsg(msgID uint32, data []byte) error
|
|
// SetContext 设置当前连接的上下文
|
|
SetContext(ctx context.Context)
|
|
// GetContext 获取当前连接的上下文
|
|
GetContext() context.Context
|
|
}
|