Documentation ¶
Index ¶
- Constants
- Variables
- type ConnectionState
- type ConnectionStateDetail
- type HubInterface
- type HubReaderInterface
- type MdnsEntry
- type MdnsInterface
- type MdnsProviderInterface
- type MdnsReportInterface
- type MdnsResolveCB
- type RemoteService
- type ServiceDetails
- func (s *ServiceDetails) AutoAccept() bool
- func (s *ServiceDetails) ConnectionStateDetail() *ConnectionStateDetail
- func (s *ServiceDetails) DeviceType() string
- func (s *ServiceDetails) IPv4() string
- func (s *ServiceDetails) SKI() string
- func (s *ServiceDetails) SetAutoAccept(value bool)
- func (s *ServiceDetails) SetConnectionStateDetail(detail *ConnectionStateDetail)
- func (s *ServiceDetails) SetDeviceType(deviceType string)
- func (s *ServiceDetails) SetIPv4(ipv4 string)
- func (s *ServiceDetails) SetShipID(shipid string)
- func (s *ServiceDetails) SetTrusted(trust bool)
- func (s *ServiceDetails) ShipID() string
- func (s *ServiceDetails) Trusted() bool
- type ShipConnectionDataReaderInterface
- type ShipConnectionDataWriterInterface
- type ShipConnectionInfoProviderInterface
- type ShipConnectionInterface
- type WebsocketDataReaderInterface
- type WebsocketDataWriterInterface
Constants ¶
const ShipWebsocketSubProtocol = "ship" // SHIP 10.2: sub protocol is required for websocket connections
Variables ¶
var ErrConnectionNotFound = errors.New("no connection for provided SKI found")
ErrConnectionNotFound that there was no active connection for a given SKI found
var ErrServiceNotPaired = errors.New("the provided SKI is not paired")
ErrServiceNotPaired if the given SKI is not paired yet
Functions ¶
This section is empty.
Types ¶
type ConnectionState ¶
type ConnectionState uint
connection state for global usage, e.g. UI
const ( ConnectionStateNone ConnectionState = iota // The initial state, when no pairing exists ConnectionStateQueued // The connection request has been started and is pending connection initialization ConnectionStateInitiated // This service initiated the connection process ConnectionStateReceivedPairingRequest // A remote service initiated the connection process ConnectionStateInProgress // The connection handshake is in progress ConnectionStateTrusted // The connection is trusted on both ends ConnectionStatePin // PIN processing, not supported right now! ConnectionStateCompleted // The connection handshake is completed from both ends ConnectionStateRemoteDeniedTrust // The remote service denied trust ConnectionStateError // The connection handshake resulted in an error )
type ConnectionStateDetail ¶
type ConnectionStateDetail struct {
// contains filtered or unexported fields
}
the connection state of a service and error if applicable
func NewConnectionStateDetail ¶
func NewConnectionStateDetail(state ConnectionState, err error) *ConnectionStateDetail
func (*ConnectionStateDetail) Error ¶
func (c *ConnectionStateDetail) Error() error
func (*ConnectionStateDetail) SetError ¶
func (c *ConnectionStateDetail) SetError(err error)
func (*ConnectionStateDetail) SetState ¶
func (c *ConnectionStateDetail) SetState(state ConnectionState)
func (*ConnectionStateDetail) State ¶
func (c *ConnectionStateDetail) State() ConnectionState
type HubInterface ¶
type HubInterface interface { // Start the ConnectionsHub with all its services Start() // close all connections Shutdown() // return the service for a SKI ServiceForSKI(ski string) *ServiceDetails // Provide the current pairing state for a SKI PairingDetailForSki(ski string) *ConnectionStateDetail // Enables or disables to automatically accept incoming pairing and connection requests // // Default: false SetAutoAccept(bool) // Pair with the SKI RegisterRemoteSKI(ski string) // Unpair the SKI UnregisterRemoteSKI(ski string) // Disconnect a connection to an SKI DisconnectSKI(ski string, reason string) // Cancels the pairing process for a SKI CancelPairingWithSKI(ski string) }
Interface for handling the server and remote connections
type HubReaderInterface ¶
type HubReaderInterface interface { // report a connection to a SKI RemoteSKIConnected(ski string) // report a disconnection to a SKI RemoteSKIDisconnected(ski string) // report an approved handshake by a remote device SetupRemoteDevice(ski string, writeI ShipConnectionDataWriterInterface) ShipConnectionDataReaderInterface // report all currently visible EEBUS services VisibleRemoteServicesUpdated(entries []RemoteService) // Provides the SHIP ID the remote service reported during the handshake process // This needs to be persisted and passed on for future remote service connections // when using `PairRemoteService` ServiceShipIDUpdate(ski string, shipdID string) // Provides the current pairing state for the remote service // This is called whenever the state changes and can be used to // provide user information for the pairing/connection process ServicePairingDetailUpdate(ski string, detail *ConnectionStateDetail) // return if the user is still able to trust the connection AllowWaitingForTrust(ski string) bool }
Interface to pass information from the hub to the eebus service
Implemented by eebus service implementation, used by Hub
type MdnsInterface ¶
type MdnsInterface interface { Start(cb MdnsReportInterface) error Shutdown() AnnounceMdnsEntry() error UnannounceMdnsEntry() SetAutoAccept(bool) RequestMdnsEntries() }
implemented by mdns, used by Hub
type MdnsProviderInterface ¶
type MdnsProviderInterface interface { CheckAvailability() bool Shutdown() Announce(serviceName string, port int, txt []string) error Unannounce() ResolveEntries(cb MdnsResolveCB) }
implemented by mdns providers, used by mdns
type MdnsReportInterface ¶
implemented by Hub, used by mdns
type MdnsResolveCB ¶
type MdnsResolveCB func(elements map[string]string, name, host string, addresses []net.IP, port int, remove bool)
implemented by mdns, used by Providers
type RemoteService ¶
type ServiceDetails ¶
type ServiceDetails struct {
// contains filtered or unexported fields
}
generic service details about the local or any remote service
func NewServiceDetails ¶
func NewServiceDetails(ski string) *ServiceDetails
create a new ServiceDetails record with a SKI
func (*ServiceDetails) AutoAccept ¶
func (s *ServiceDetails) AutoAccept() bool
func (*ServiceDetails) ConnectionStateDetail ¶
func (s *ServiceDetails) ConnectionStateDetail() *ConnectionStateDetail
func (*ServiceDetails) DeviceType ¶
func (s *ServiceDetails) DeviceType() string
func (*ServiceDetails) IPv4 ¶
func (s *ServiceDetails) IPv4() string
func (*ServiceDetails) SKI ¶
func (s *ServiceDetails) SKI() string
func (*ServiceDetails) SetAutoAccept ¶
func (s *ServiceDetails) SetAutoAccept(value bool)
func (*ServiceDetails) SetConnectionStateDetail ¶
func (s *ServiceDetails) SetConnectionStateDetail(detail *ConnectionStateDetail)
func (*ServiceDetails) SetDeviceType ¶
func (s *ServiceDetails) SetDeviceType(deviceType string)
func (*ServiceDetails) SetIPv4 ¶
func (s *ServiceDetails) SetIPv4(ipv4 string)
func (*ServiceDetails) SetShipID ¶
func (s *ServiceDetails) SetShipID(shipid string)
func (*ServiceDetails) SetTrusted ¶
func (s *ServiceDetails) SetTrusted(trust bool)
func (*ServiceDetails) ShipID ¶
func (s *ServiceDetails) ShipID() string
func (*ServiceDetails) Trusted ¶
func (s *ServiceDetails) Trusted() bool
type ShipConnectionDataReaderInterface ¶
type ShipConnectionDataReaderInterface interface {
HandleShipPayloadMessage(message []byte)
}
Used to pass an incoming SPINE message from a SHIP connection to the proper DeviceRemote
Implemented by spine DeviceRemote, used by ShipConnection
type ShipConnectionDataWriterInterface ¶
type ShipConnectionDataWriterInterface interface {
WriteShipMessageWithPayload(message []byte)
}
Used to pass an outgoing SPINE message from a DeviceLocal to the SHIP connection
Implemented by ShipConnection, used by spine DeviceLocal
type ShipConnectionInfoProviderInterface ¶
type ShipConnectionInfoProviderInterface interface { // check if the SKI is paired IsRemoteServiceForSKIPaired(string) bool // check if auto accept is true IsAutoAcceptEnabled() bool // report closing of a connection and if handshake did complete HandleConnectionClosed(ShipConnectionInterface, bool) // report the ship ID provided during the handshake ReportServiceShipID(string, string) // check if the user is still able to trust the connection AllowWaitingForTrust(string) bool // report the updated SHIP handshake state and optional error message for a SKI HandleShipHandshakeStateUpdate(string, model.ShipState) // report an approved handshake by a remote device SetupRemoteDevice(ski string, writeI ShipConnectionDataWriterInterface) ShipConnectionDataReaderInterface }
interface for getting service wide information
implemented by Hub, used by shipConnection
type ShipConnectionInterface ¶
type ShipConnectionInterface interface { DataHandler() WebsocketDataWriterInterface CloseConnection(safe bool, code int, reason string) RemoteSKI() string ApprovePendingHandshake() AbortPendingHandshake() ShipHandshakeState() (model.ShipMessageExchangeState, error) }
type WebsocketDataReaderInterface ¶
type WebsocketDataReaderInterface interface { // called for each incoming message HandleIncomingWebsocketMessage([]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 WebsocketDataWriterInterface ¶
type WebsocketDataWriterInterface interface { // initialize data processing InitDataProcessing(WebsocketDataReaderInterface) // send data via the connection to the remote device WriteMessageToWebsocketConnection([]byte) error // close the data connection CloseDataConnection(closeCode int, reason string) // report if the data connection is closed and the error if availab le IsDataConnectionClosed() (bool, error) }
interface for handling the actual remote device data connection
implemented by websocketConnection, used by ShipConnection