pkg

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Uid                string
	Uuid               string //ws连接ID
	Key                string //浏览器随机key
	Hub                *Hub
	Socket             *websocket.Conn // ws连接
	Message            chan []byte     //ws连接的消息管道
	PingPeriod         time.Duration
	ReadDeadline       time.Duration
	WriteDeadline      time.Duration
	HeartbeatFailTimes int
	sync.RWMutex
	State uint8 //状态

}

func (*Client) Heartbeat

func (c *Client) Heartbeat()

Heartbeat 实现隐式心跳

func (*Client) OpenWs

func (c *Client) OpenWs(writer http.ResponseWriter, request *http.Request) (*Client, bool)

func (*Client) ReadPump

func (c *Client) ReadPump(callbackOnMessage func(messageType int, receiveData []byte), callbackOnError func(err error), callbackOnclose func())

func (*Client) SendMessage

func (c *Client) SendMessage(messageType int, message string) error

type Hub

type Hub struct {
	//上线注册
	Register chan *Client
	//下线注销
	UnRegister chan *Client
	//所有在线客户端的内存地址
	Clients map[*Client]bool
}
var (
	WebsocketHub *Hub
)

func CreateHubFactory

func CreateHubFactory() *Hub

func (*Hub) Run

func (h *Hub) Run()

type UbxErr

type UbxErr struct {
	Handler string
	Msg     string
}

func New

func New(handler, msg string) *UbxErr

func (*UbxErr) Attach

func (e *UbxErr) Attach(msg interface{}) *UbxErr

func (*UbxErr) Error

func (e *UbxErr) Error() string

Jump to

Keyboard shortcuts

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