代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。