model

package
v0.0.0-...-67d91c4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HashSize = 10

Functions

This section is empty.

Types

type CmdData

type CmdData struct {
	Cmd   string      `json:"cmd"`
	Data  interface{} `json:"data"` // obj
	Msg   string      `json:"msg"`
	Code  int         `json:"code"`
	Token string      `json:"token"`
}

func NewCmdData

func NewCmdData() *CmdData

func (*CmdData) Byte

func (c *CmdData) Byte() []byte

func (*CmdData) GetUid

func (c *CmdData) GetUid() string

func (*CmdData) SendCmd

func (c *CmdData) SendCmd(cmd string, data interface{}) []byte

func (*CmdData) SendMsg

func (c *CmdData) SendMsg(str string, code int) []byte

func (*CmdData) VerifyToken

func (c *CmdData) VerifyToken(clientUid int64) bool

type TCPHeartBeatCache

type TCPHeartBeatCache struct {
}

func (*TCPHeartBeatCache) Add

func (t *TCPHeartBeatCache) Add(token string)

func (*TCPHeartBeatCache) Del

func (t *TCPHeartBeatCache) Del(token string)

func (*TCPHeartBeatCache) Has

func (t *TCPHeartBeatCache) Has(token string) bool

type TcpClient

type TcpClient struct {
	Conn      net.Conn
	UserID    string      // 用户id唯一的
	IP        string      // 当前连接的ip
	DeviceID  string      // 当前连接的设备id
	Source    string      // 设备类型
	HeartBeat chan []byte // 心跳包
}

func (*TcpClient) GetConn

func (tcp *TcpClient) GetConn() net.Conn

func (*TcpClient) GetIP

func (tcp *TcpClient) GetIP() string

func (*TcpClient) Send

func (tcp *TcpClient) Send(msg []byte)

type TcpHashTable

type TcpHashTable struct {
	Table map[int64]*tcpNode // UserID 用户id 哈希后作为key
	Size  int64
}

func InitTcpConnTable

func InitTcpConnTable() *TcpHashTable

func TcpClientTable

func TcpClientTable() *TcpHashTable

提供调用

func (*TcpHashTable) Del

func (table *TcpHashTable) Del(value *TcpClient)

func (*TcpHashTable) Get

func (table *TcpHashTable) Get(uid string) (date *TcpClient, err error)

func (*TcpHashTable) Insert

func (table *TcpHashTable) Insert(value *TcpClient)

type UdpClient

type UdpClient struct {
	Conn        *net.UDPAddr
	UserID      string // 用户id唯一的
	IP          string // 当前连接的ip
	DeviceID    string // 当前连接的设备id
	Source      string // 设备类型
	UDPListener *net.UDPConn
}

func (*UdpClient) GetConn

func (udp *UdpClient) GetConn() *net.UDPAddr

func (*UdpClient) GetIP

func (udp *UdpClient) GetIP() string

func (*UdpClient) Send

func (udp *UdpClient) Send(msg []byte)

type UdpHashTable

type UdpHashTable struct {
	Table map[int64]*udpNode // UserID 用户id 哈希后作为key
	Size  int64
}

func InitUdpConnTable

func InitUdpConnTable() *UdpHashTable

func UdpClientTable

func UdpClientTable() *UdpHashTable

提供调用

func (*UdpHashTable) Del

func (table *UdpHashTable) Del(value *UdpClient)

func (*UdpHashTable) Get

func (table *UdpHashTable) Get(uid string) (date *UdpClient, err error)

func (*UdpHashTable) Insert

func (table *UdpHashTable) Insert(value *UdpClient)

type WsClient

type WsClient struct {
	Conn       *websocket.Conn
	UserID     string      // 用户id唯一的
	IP         string      // 当前连接的ip
	DeviceID   string      // 当前连接的设备id
	DeviceType string      // 设备类型
	HeartBeat  chan []byte // 心跳包
}

func (*WsClient) GetConn

func (ws *WsClient) GetConn() *websocket.Conn

func (*WsClient) GetIP

func (ws *WsClient) GetIP() string

func (*WsClient) Send

func (ws *WsClient) Send(msg []byte)

type WsHashTable

type WsHashTable struct {
	Table map[int64]*wsNode // UserID 用户id 哈希后作为key
	Size  int64
}

func InitWsConnTable

func InitWsConnTable() *WsHashTable

func WsClientTable

func WsClientTable() *WsHashTable

提供调用

func (*WsHashTable) Del

func (table *WsHashTable) Del(value *WsClient)

func (*WsHashTable) Get

func (table *WsHashTable) Get(uid string) (date *WsClient, err error)

func (*WsHashTable) Insert

func (table *WsHashTable) Insert(value *WsClient)

Jump to

Keyboard shortcuts

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