2 Star 1 Fork 0

法马智慧/fmgo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
conn.go 729 Bytes
一键复制 编辑 原始数据 按行查看 历史
Asdybing 提交于 2022-04-08 10:17 . 增加tcp封包
package tcpx
import (
"net"
)
/* tcp 连接定义 */
// TCPType tcp连接类型
type TCPType = int
const (
// TCPSocketType tcp连接
TCPSocketType = iota
// WebSocketType WebSocket连接
WebSocketType
)
// Conn 自定义连接对象结构体,可以存储tcp或webSocket连接对象
type Conn struct {
net.Conn
connType TCPType // 连接对象类型
clientID string // 客户端id
}
// SendMessage 发送消息,参数为自己报文结构体
func (c *Conn) SendMessage(data []byte) (int, error) {
return c.Write(data)
}
// GetClientID 获取当前连接id
func (c *Conn) GetClientID() string {
return c.clientID
}
// GetConnType 获取连接类型
func (c *Conn) GetConnType() TCPType {
return c.connType
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fmpt/fmgo.git
git@gitee.com:fmpt/fmgo.git
fmpt
fmgo
fmgo
v1.2.11

搜索帮助