websocket

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn client connect

func NewConn

func NewConn() *Conn

NewConn init new connection

func (*Conn) Close

func (c *Conn) Close()

Close connection

func (*Conn) Headers

func (c *Conn) Headers() http.Header

Headers request headers

func (*Conn) OnClose

func (c *Conn) OnClose(cb func(string))

OnClose event on close connection

func (*Conn) Send

func (c *Conn) Send(v []byte)

Send message

func (*Conn) UUID

func (c *Conn) UUID() string

UUID get conn unique ID

func (*Conn) Upgrade

func (c *Conn) Upgrade(w http.ResponseWriter, r *http.Request, handler Handler) (err error)

Upgrade tcp connection

type Connector

type Connector interface {
	UUID() string
	Headers() http.Header
	Send(v []byte)
	OnClose(cb func(string))
	Close()
}

Connector interface

type Handler

type Handler func([]byte, Connector)

Handler request processor

type Hub

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

Hub connections store

func NewHub

func NewHub(handler Handler) *Hub

NewHub init hub

func (*Hub) Add

func (h *Hub) Add(c *Conn)

Add connection to hub

func (*Hub) CloseAll

func (h *Hub) CloseAll()

CloseAll cloase all connection

func (*Hub) Down

func (h *Hub) Down() error

Down hub

func (*Hub) SendAll

func (h *Hub) SendAll(v []byte)

SendAll broadcast send message

func (*Hub) ServeHTTP

func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP http handler

func (*Hub) Up

func (h *Hub) Up() error

Up hub

Jump to

Keyboard shortcuts

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