fospws

package
v0.0.0-...-bb09860 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChanError = errors.New("channel error when recieving response")

ErrChanError is returned when a response should be read from a channel but the channel returns an error instead.

View Source
var ErrRequestTimeout = errors.New("request timed out")

ErrRequestTimeout is returned when a response should be read from a channel but the timeout is reached.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	RequestTimeout time.Duration
	// contains filtered or unexported fields
}

Connection represents a generic FOSP connection. It is the base for ServerConnection and for Client.

func NewConnection

func NewConnection(ws *websocket.Conn) *Connection

NewConnection creates a new FOSP connection from an existing WebSocket connection.

func OpenConnection

func OpenConnection(remoteDomain string) (*Connection, error)

OpenConnection creates a new FOSP connection to the remoteDomain. It will open a WebSocket connection to this remoteDomain or return an error.

func (*Connection) Close

func (c *Connection) Close()

Close this connection and clean up. TODO: Websocket should send close message before tearing down the connection

func (*Connection) RegisterMessageHandler

func (c *Connection) RegisterMessageHandler(handler MessageHandler)

RegisterMessageHandler accepts a function that should be called when a Message is received.

func (*Connection) Send

func (c *Connection) Send(msg fosp.Message, seq ...uint64)

Send queues an Message to be send.

func (*Connection) SendNumberedMessage

func (c *Connection) SendNumberedMessage(msg *NumberedMessage)

func (*Connection) SendRequest

func (c *Connection) SendRequest(req *fosp.Request) (*fosp.Response, error)

SendRequest will send a Request and block until a Response is returned or timedout.

type MessageHandler

type MessageHandler interface {
	HandleMessage(*NumberedMessage)
}

MessageHandler is the interface of objects that know how to process Messages.

type NumberedMessage

type NumberedMessage struct {
	fosp.Message
	Seq        uint64
	BinaryBody bool
}

Jump to

Keyboard shortcuts

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