Documentation
¶
Index ¶
Constants ¶
const ( ShipRoleServer shipRole = "server" ShipRoleClient shipRole = "client" )
const (
// SHIP 9.2: Set maximum fragment length to 1024 bytes
MaxMessageSize = 1024
)
Variables ¶
This section is empty.
Functions ¶
func NewWebsocketConnection ¶
create a new websocket based shipDataProcessing implementation
Types ¶
type ConnectionHandler ¶
type ConnectionHandler interface {
HandleClosedConnection(connection *ShipConnection)
}
implemented by connectionsHub and used by shipConnection
type ShipConnection ¶
type ShipConnection struct {
// The remote SKI
RemoteSKI string
// the handler for sending messages on the data connection
DataHandler ShipDataConnection
// contains filtered or unexported fields
}
A ShipConnection handles the data connection and coordinates SHIP and SPINE messages i/o
func NewConnectionHandler ¶
func NewConnectionHandler(dataProvider ShipServiceDataProvider, dataHandler ShipDataConnection, deviceLocalCon spine.DeviceLocalConnection, role shipRole, localShipID, remoteSki, remoteShipId string) *ShipConnection
func (*ShipConnection) CloseConnection ¶
func (c *ShipConnection) CloseConnection(safe bool, reason string)
close this ship connection
func (*ShipConnection) HandleIncomingShipMessage ¶
func (c *ShipConnection) HandleIncomingShipMessage(message []byte)
route the incoming message to either SHIP or SPINE message handlers
func (*ShipConnection) ReportConnectionError ¶
func (c *ShipConnection) ReportConnectionError(err error)
the websocket data connection was closed from remote
func (*ShipConnection) WriteSpineMessage ¶
func (c *ShipConnection) WriteSpineMessage(message []byte)
SpineDataConnection interface implementation
type ShipDataConnection ¶
type ShipDataConnection interface {
// initialize data processing
InitDataProcessing(ShipDataProcessing)
// send data via the connection to the remote device
WriteMessageToDataConnection([]byte) error
// close the data connection
CloseDataConnection()
// report if the data connection is closed
IsDataConnectionClosed() bool
}
interface for handling the actual remote device data connection
implemented by websocketConnection, used by ShipConnection
type ShipDataProcessing ¶
type ShipDataProcessing interface {
// called for each incoming message
HandleIncomingShipMessage([]byte)
// called if the data connection is closed unsafe
// e.g. due to connection issues
ReportConnectionError(error)
}
interface for handling incoming data
implemented by shipConnection, used by websocketConnection
type ShipServiceDataProvider ¶
type ShipServiceDataProvider interface {
// check if the SKI is paired
IsRemoteServiceForSKIPaired(string) bool
// report closing of a connection and if handshake did complete
HandleConnectionClosed(*ShipConnection, bool)
// report the ship ID provided during the handshake
ReportServiceShipID(string, string)
}
interface for getting service wide information
implemented by connectionsHub, used by shipConnection