wswrapper

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

wswrapper

Wrapper of gorilla/websocket

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebsocketClient

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

Client is a middleman between the websocket connection and the hub.

func (*WebsocketClient) Connection added in v1.1.0

func (c *WebsocketClient) Connection() *websocket.Conn

func (*WebsocketClient) Hub added in v1.1.0

func (c *WebsocketClient) Hub() *WebsocketHub

func (*WebsocketClient) Id added in v1.2.2

func (c *WebsocketClient) Id() int

func (*WebsocketClient) Send added in v1.1.0

func (c *WebsocketClient) Send(msg []byte)

type WebsocketEvent

type WebsocketEvent struct {
	Kind   WebsocketEventKind
	Client *WebsocketClient
	Msg    *[]byte
	Err    error
}

type WebsocketEventKind

type WebsocketEventKind int
const (
	EVENT_RECIEVE WebsocketEventKind = iota
	EVENT_REGISTER
	EVENT_UNREGISTER
	EVENT_ERROR
)

type WebsocketHub

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

func NewHub

func NewHub() *WebsocketHub

func (*WebsocketHub) AddClient

func (h *WebsocketHub) AddClient(w http.ResponseWriter, r *http.Request)

func (*WebsocketHub) AddUpgraderOrigin added in v1.1.0

func (h *WebsocketHub) AddUpgraderOrigin(origin []string)

func (*WebsocketHub) Clients added in v1.1.0

func (h *WebsocketHub) Clients() map[*WebsocketClient]int

func (*WebsocketHub) Run

func (h *WebsocketHub) Run(event_callback func(*WebsocketEvent))

func (*WebsocketHub) Send

func (h *WebsocketHub) Send(cli *WebsocketClient, msg []byte) bool

func (*WebsocketHub) SendAll added in v1.1.0

func (h *WebsocketHub) SendAll(msg []byte)

Jump to

Keyboard shortcuts

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