ws

package
v0.0.0-...-23c13d2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 3 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 {
	Socket   *websocket.Conn
	Send     chan []byte
	OutClose chan bool
	Lock     sync.Mutex
	Status   bool
	// contains filtered or unexported fields
}

websocket 链接对象

func (*Client) Close

func (c *Client) Close()

func (*Client) Read

func (c *Client) Read(ch chan []byte)

func (*Client) Write

func (c *Client) Write()

type Message

type Message struct {
	Code    int         `json:"code,omitempty"`
	Message string      `json:"message,omitempty"`
	Content interface{} `json:"data,omitempty"`
}

消息结构提

type SendMessage

type SendMessage struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type WsManager

type WsManager struct {
	Clients    map[string]*Client
	Broadcast  chan []byte
	Register   chan *Client //链接
	Unregister chan *Client //断开链接
}

websocket管理器

var WsMag WsManager

func NewMag

func NewMag() *WsManager

func (*WsManager) Reg

func (wsmag *WsManager) Reg(uuid string, conn *websocket.Conn) *Client

注册ws链接

func (*WsManager) SendMain

func (wsmag *WsManager) SendMain(code int, data interface{})

func (*WsManager) SetUp

func (wsmag *WsManager) SetUp()

Jump to

Keyboard shortcuts

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