pwshandler

package module
v0.0.0-...-d809dc5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: BSD-2-Clause Imports: 3 Imported by: 0

README

Pool WebSocket handler

GoDoc

PoolHandler is handler which may be useful at the projects where websocket connections are divided into a groups (pools) with a common group data.

$ go get -u github.com/ivan1993spb/pwshandler

Documentation

Overview

PoolHandler is handler which may be useful at the projects where websocket connections are divided into a groups (pools) with access to common data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PoolHandler

func PoolHandler(poolMgr PoolManager, connMgr ConnManager, verifier RequestVerifier) http.Handler

PoolHandler returns WS handler which receives websocket requests and merges connection goroutines in a pools (groups) with common data. poolMgr is a storage of groups and connections. poolMgr divides handled connections into groups, stores common group data and passes common data to goroutines for processing ws connections. connMgr contains handler for processing of ws connection. connMgr gets common group and ws connection. verifier must verify connections. If was passed nil instead verifier connections will not verified

Types

type ConnManager

type ConnManager interface {
	// Handle handles connections using passed common environment data
	Handle(ws *websocket.Conn, data Environment) error
	// HandleError processes an errors
	HandleError(ws *websocket.Conn, err error)
}

ConnManager contains methods for processing websocket connections with passed common group data

type Environment

type Environment interface{}

Environment is a common data for ws connections in one pool (group)

type PoolManager

type PoolManager interface {
	// AddConn creates connection to a pool and returns environment data
	AddConn(ws *websocket.Conn) (Environment, error)
	// DelConn removes passed connection from a pool if it exists in pool
	DelConn(ws *websocket.Conn) error
}

PoolManager is common interface for a structures which merge websocket connections in a pools (groups) with access to common data

type RequestVerifier

type RequestVerifier interface {
	Verify(ws *websocket.Conn) error
}

RequestVerifier verifies requests. It has to verify a request data such a passed hashes, certificates, remote addr, token, passed headers or something else

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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