ws

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: GPL-3.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgTypeError     = "error"
	MsgTypeOk        = "ok"
	MsgTypeEcho      = "echo"
	MsgTypeAuth      = "auth"
	MsgTypeToken     = "token"
	MsgTypeJoin      = "join"
	MsgTypeJoined    = "joined"
	MsgTypeChanIn    = "chan_in"
	MsgTypeChanOut   = "chan_out"
	MsgTypeDBCreated = "db_created"
	MsgTypeDBUpdated = "db_updated"
	MsgTypeDBDeleted = "db_deleted"
)

Variables

This section is empty.

Functions

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request)

serveWs handles websocket requests from the peer.

Types

type Command

type Command struct {
	SID     string `json:"sid"`
	Type    string `json:"type"`
	Data    string `json:"data"`
	Channel string `json:"channel"`
	Token   string `json:"token"`
}

func (Command) IsDBEvent

func (msg Command) IsDBEvent() bool

type Hub

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

func NewHub

func NewHub(v Validator) *Hub

func (*Hub) Publish

func (h *Hub) Publish(msg Command, channel string)

Publish sends a message to all socket in that channel

func (*Hub) Run

func (h *Hub) Run()

type Socket

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

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

type Validator

type Validator func(interface{}) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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