Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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.