sockets

package
v0.0.0-...-4461672 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Managers = make(map[string]*ClientManager)
)

Managers - 用 name 来区分 manager, 不是很好复用连接 后期还是需要引入 Room 的概念

Functions

func ServeWs

func ServeWs(manager *ClientManager, w http.ResponseWriter, r *http.Request)

ServeWs 这里是要帮助 "客户端" 创建连接 & 实例化 Client & 注册该 Client

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 是存在于服务端对连接的抽象描述 & 每一个连接都需要初始化一个 Client Instance

func (*Client) Conn

func (c *Client) Conn() *websocket.Conn

Conn return physical connection

func (*Client) Destory

func (c *Client) Destory()

Destory exports destory()

type ClientManager

type ClientManager struct {
	Broadcast chan []byte
	// contains filtered or unexported fields
}

ClientManager stands for the hub of clients

func DefaultManager

func DefaultManager() *ClientManager

DefaultManager - as it looks

func ManagerByName

func ManagerByName(name string) *ClientManager

ManagerByName find manager by name

func NewManger

func NewManger() *ClientManager

NewManger returns an instance of ClientManger

func (*ClientManager) Clients

func (manager *ClientManager) Clients() map[*Client]bool

Clients returns all connected clients

func (*ClientManager) Close

func (manager *ClientManager) Close()

Close release resources

func (*ClientManager) Exec

func (manager *ClientManager) Exec()

Exec || activate the manager

Jump to

Keyboard shortcuts

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