socket

package
v0.0.0-...-d221b79 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartMessenger

func StartMessenger()

StartMessenger starts the messenger for reading

func UpgradeToWebsocket

func UpgradeToWebsocket(manager *Manager) func(context echo.Context) error

UpgradeToWebsocket upgrades a connection to a websocket and creates a client for the connection

Types

type Client

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

A Client manages a specific websocket connection to a client

type EventHandler

type EventHandler interface {
	// OnClientConnect is called once each time a new client connects to the manager.
	OnClientConnect(sendToClient chan interface{})

	// OnEventReceived will be called each time any client sends an event.
	OnEventReceived(event interface{}, sendToAll chan interface{})
}

EventHandler is an interface for handling websocket events

type Manager

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

A Manager maintains and manages the list of websocket connections

func GetManager

func GetManager() *Manager

GetManager returns the manager, and creates a new one if it has not made one before

func (*Manager) SetEventHandler

func (m *Manager) SetEventHandler(handler EventHandler)

SetEventHandler sets the eventHandler for the websocket manager

func (*Manager) SetMessenger

func (m *Manager) SetMessenger(mess *messenger.Messenger)

SetMessenger sets the event Messenger for the websocket manager

func (*Manager) WriteToSockets

func (m *Manager) WriteToSockets(e interface{})

WriteToSockets writes events out to the clients on the socket connections

Jump to

Keyboard shortcuts

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