www

package
v0.0.0-...-179c293 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWSActions

func NewWSActions(dClient *data.Client) map[string]WSAction

Types

type Server

type Server struct {
	http.Server
}

func New

func New(cert, key, host string, port int, dStore datastore.Datastore) (*Server, error)

TODO load a config to choose a datastore

func (*Server) Run

func (s *Server) Run() error

type WS

type WS struct {
	Upgrader *websocket.Upgrader
	Logger   *log.Logger
	Actions  map[string]WSAction
}

WS is the struct resprenting a websocket server handler

func NewWS

func NewWS(bufferSize int, actions map[string]WSAction) *WS

NewWS returns a pointer to a WS instance

func (*WS) HandleServerError

func (ws *WS) HandleServerError(res http.ResponseWriter, req *http.Request, err error)

HandleServerError handles WS server errors by logging them and sending a response back of the error itself

func (*WS) HandleUpgrades

func (ws *WS) HandleUpgrades(res http.ResponseWriter, req *http.Request)

HandleUpgrades handles a HTTP upgrade to a websocket

func (*WS) HandleWSError

func (ws *WS) HandleWSError(conn *websocket.Conn, err error)

HandleWSError handles errors once the connection has been upgraded

func (*WS) Route

func (ws *WS) Route(conn *websocket.Conn)

Route routes messages between a websocket connection

type WSAction

type WSAction func(conn *websocket.Conn, msg *wsOuterMessage) error

WSAction is a type of function that handles a WS message

Jump to

Keyboard shortcuts

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