conn

package
v0.0.0-...-d272d5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2021 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CoonTypeTCP int8 = 1 // tcp连接
	ConnTypeWS  int8 = 2 // websocket连接
)

Variables

View Source
var ConnsManager = sync.Map{}

Functions

func DeleteConn

func DeleteConn(deviceId int64)

DeleteConn 删除

func SetConn

func SetConn(deviceId int64, conn *Conn)

SetConn 存储

Types

type Conn

type Conn struct {
	CoonType int8            // 连接类型
	TCP      *gn.Conn        // tcp连接
	WSMutex  sync.Mutex      // WS写锁
	WS       *websocket.Conn // websocket连接
	UserId   int64           // 用户ID
	DeviceId int64           // 设备ID
	RoomId   int64           // 订阅的房间ID
	Element  *list.Element   // 链表节点
	S        *service.ShopAdmin
}

func GetConn

func GetConn(deviceId int64) *Conn

GetConn 获取

func (*Conn) Close

func (c *Conn) Close() error

Close 关闭

func (*Conn) GetAddr

func (c *Conn) GetAddr() string

func (*Conn) HandleMessage

func (c *Conn) HandleMessage(bytes []byte)

HandleMessage todo 消息处理

func (*Conn) Heartbeat

func (c *Conn) Heartbeat()

Heartbeat todo 心跳

func (*Conn) Write

func (c *Conn) Write(bytes []byte) error

Write 写入数据

func (*Conn) WriteToWS

func (c *Conn) WriteToWS(bytes []byte) error

WriteToWS 消息写入WebSocket

type Handler

type Handler struct {
	S *service.ShopAdmin
}

func (*Handler) OnClose

func (*Handler) OnClose(c *gn.Conn, err error)

func (*Handler) OnConnect

func (h *Handler) OnConnect(c *gn.Conn)

func (*Handler) OnMessage

func (*Handler) OnMessage(c *gn.Conn, bytes []byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL