websocket

package
v0.0.0-...-78e7222 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Time allowed to write a message to the peer.
	WriteWait = 10 * time.Second
	// Time allowed to read the next pong message from the peer.
	PongWait = 30 * time.Second
	// Send pings to peer with this period. Must be less than pongWait.
	PingPeriod = (PongWait * 9) / 10
	// Maximum message size allowed from peer.
	MaxMessageSize = 4096
)

Variables

This section is empty.

Functions

func NewClientHelper

func NewClientHelper(
	Conn *websocket.Conn,
	Hub *Hub,
) *clientHelper

Types

type ContextProvider

type ContextProvider struct {
	// The websocket ContextProvider
	Conn *websocket.Conn
	// Buffered channel of outbound messages
	Send  chan []byte
	Host  string
	Port  string
	Path  string
	Close chan bool
}

func NewContextProvider

func NewContextProvider(
	Host string,
	Port string,
	Path string,
) *ContextProvider

func (*ContextProvider) Run

func (cp *ContextProvider) Run() error

func (*ContextProvider) StartRX

func (cp *ContextProvider) StartRX() error

func (*ContextProvider) StartTX

func (cp *ContextProvider) StartTX() error

type Hub

type Hub struct {
	/*
	   A central hub will receive all incoming messages and broadcast them
	   to all registered "Subscriber"s
	   (i.e. the Subscriber structures in the clients map)
	*/
	Clients    map[Subscriber]bool
	Broadcast  chan Message
	Register   chan Subscriber
	Unregister chan Subscriber
	// contains filtered or unexported fields
}

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	Type        message.ExoWSMsgType `json:"type"`
	SerialData  string               `json:"serialData"`
	ReBroadcast bool                 `json:"reBroadcast"`
}

type Subscriber

type Subscriber interface {
	Send(message Message) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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