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: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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