shandler

package module
v0.0.0-...-761bbf8 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2019 License: MIT Imports: 5 Imported by: 0

README

Shandler - WebSocket Handler

Manages and simplifies https://github.com/nhooyr/websocket websocket server implementations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHandler

type ClientHandler interface {
	Connected()
	Disconnected()
	Handle(data []byte)
	HandleBinary(data []byte)
	Write(data []byte)
	WriteBinary(data []byte)
}

type ClientSpawner

type ClientSpawner func(HTTPObjects) ClientHandler

ClientSpawner creates a new client handler

type HTTPObjects

type HTTPObjects struct {
	Handler *Handler
	Socket  *websocket.Conn
	Writer  http.ResponseWriter
	Request *http.Request
}

type Handler

type Handler struct {
	Log *zap.Logger
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(log *zap.Logger, clientSpawner ClientSpawner) *Handler

NewHandler creates a new handler. Takes a logger and a client spawner function. The spawner will be called for every new client connection.

func (*Handler) Broadcast

func (h *Handler) Broadcast(from ClientHandler, messageType websocket.MessageType, data []byte)

func (*Handler) Handle

func (h *Handler) Handle(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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