socket

package
v0.0.0-...-5385bce Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpgradeToWebsocket

func UpgradeToWebsocket(manager *Manager) func(ctx 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 is connected.
	// use sendToClient to send events to the new client.
	OnClientConnect(sendToClient chan events.Event)

	// OnEventReceived will be called each time _any_ client sends an event.
	// event is the event recieved, and events can be sent back to _all_ clients using sendToAll.
	OnEventReceived(event events.Event, sendToAll chan events.Event)
}

An EventHandler is a struct that handles websocket events

type Manager

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

A Manager manages a group of websocket connections

func NewManager

func NewManager() *Manager

NewManager returns new manager.

func (*Manager) SetEventHandler

func (m *Manager) SetEventHandler(handler EventHandler)

SetEventHandler sets the event handler for the websocket manager

Jump to

Keyboard shortcuts

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