websocket

package
v0.0.0-...-83e654d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Receiver

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

Receiver is a helper class, for managing a combined pull push on a topic. It is used for implementation of the + (receive) command in the guble protocol.

func NewReceiverFromCmd

func NewReceiverFromCmd(
	applicationID string,
	cmd *protocol.Cmd,
	sendChannel chan []byte,
	router router.Router,
	userID string) (rec *Receiver, err error)

NewReceiverFromCmd parses the info in the command

func (*Receiver) Start

func (rec *Receiver) Start() error

Start starts the receiver loop

func (*Receiver) Stop

func (rec *Receiver) Stop() error

Stop stops/cancels the receiver

type WSConnection

type WSConnection interface {
	Close()
	Send(bytes []byte) (err error)
	Receive(bytes *[]byte) (err error)
}

WSConnection is a wrapper interface for the needed functions of the websocket.Conn It is introduced for testability of the WSHandler

type WSHandler

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

WSHandler is a struct used for handling websocket connections on a certain prefix.

func NewWSHandler

func NewWSHandler(router router.Router, prefix string) (*WSHandler, error)

NewWSHandler returns a new WSHandler.

func (*WSHandler) GetPrefix

func (handler *WSHandler) GetPrefix() string

GetPrefix returns the prefix. It is a part of the service.endpoint implementation.

func (*WSHandler) ServeHTTP

func (handler *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is an http.Handler. It is a part of the service.endpoint implementation.

type WebSocket

type WebSocket struct {
	*WSHandler
	WSConnection
	// contains filtered or unexported fields
}

WebSocket struct represents a websocket.

func NewWebSocket

func NewWebSocket(handler *WSHandler, wsConn WSConnection, userID string) *WebSocket

NewWebSocket returns a new WebSocket.

func (*WebSocket) Start

func (ws *WebSocket) Start() error

Start the WebSocket (the send and receive loops). It is implementing the service.startable interface.

Jump to

Keyboard shortcuts

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