Package org.openmuc.jeebus.ship.api
Class Ship
- java.lang.Object
-
- org.openmuc.jeebus.ship.api.Ship
-
- All Implemented Interfaces:
ShipInterface
public class Ship extends java.lang.Object implements ShipInterface
-
-
Constructor Summary
Constructors Constructor Description Ship(ShipNodeConfiguration nodeConfig, ConnectionHandler connHandler)creates a new node on construction
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTrustedSki(java.lang.String ski)adding a SKI authenticates the SHIP node using that SKI.voidcreateServer(int port, java.lang.String wssPath, boolean keepAlive)static javax.jmdns.ServiceInfocreateServiceInfo(java.lang.String serviceName, java.lang.String serviceInstance, int port, TxtRecord txt)static TxtRecordcreateTxtRecord(java.lang.String id, java.lang.String path, java.lang.String ski, boolean register)static TxtRecordcreateTxtRecord(java.lang.String id, java.lang.String path, java.lang.String ski, boolean register, java.lang.String brand, java.lang.String type, java.lang.String model)java.lang.StringgetOwnSki()javax.jmdns.ServiceInfo[]getServices()returns an array with all detected services, including own serviceShipConnectionInterfaceopenConnection(java.lang.String ipAddr)opens a connection to a device/serverbooleanremoveTrustedSki(java.lang.String ski)tries to remove a ski from the trusted SKIsvoidrequestAccessMethods(ShipConnection connection)requests the access methods for the communication partner of the specified connection.voidrunConnectionDataPreparation(ShipConnection connection)run the states in connection data preparation, this method is non-blocking and the states will run asynchronouslyvoidsetAutoAcceptMode()sets the node to auto-accept-mode.voidsetClientConnectedCB(ClientConnectedCallBack clientConnectedCB)voidsetConnHandler(ConnectionHandler connHandler)sets a connection handlervoidshutDown()shuts down service discovery, all servers and clients on the node and the node itself
-
-
-
Constructor Detail
-
Ship
public Ship(ShipNodeConfiguration nodeConfig, ConnectionHandler connHandler)
creates a new node on construction- Parameters:
nodeConfig- the configuration to be used for the nodeconnHandler- connection handler
-
-
Method Detail
-
createTxtRecord
public static TxtRecord createTxtRecord(java.lang.String id, java.lang.String path, java.lang.String ski, boolean register)
-
createTxtRecord
public static TxtRecord createTxtRecord(java.lang.String id, java.lang.String path, java.lang.String ski, boolean register, java.lang.String brand, java.lang.String type, java.lang.String model)
-
createServiceInfo
public static javax.jmdns.ServiceInfo createServiceInfo(java.lang.String serviceName, java.lang.String serviceInstance, int port, TxtRecord txt)
-
createServer
public void createServer(int port, java.lang.String wssPath, boolean keepAlive)
-
openConnection
public ShipConnectionInterface openConnection(java.lang.String ipAddr)
opens a connection to a device/server- Specified by:
openConnectionin interfaceShipInterface- Parameters:
ipAddr- the IP address of the device/server to connect to. Example: "127.0.0.1:4059"- Returns:
- an object representing the connection to the device/server if the
connection was successful, else
null
-
runConnectionDataPreparation
public void runConnectionDataPreparation(ShipConnection connection)
run the states in connection data preparation, this method is non-blocking and the states will run asynchronously- Parameters:
connection- the connection that should run the connection data preparation states
-
getOwnSki
public java.lang.String getOwnSki()
-
addTrustedSki
public void addTrustedSki(java.lang.String ski)
adding a SKI authenticates the SHIP node using that SKI. The SKI of other SHIP nodes is typically communicated through theConnectionHandleror manually acquired throughShipConnectionInterface- Parameters:
ski- the ski to add to the trusted SKIs
-
removeTrustedSki
public boolean removeTrustedSki(java.lang.String ski)
tries to remove a ski from the trusted SKIs- Parameters:
ski- the ski to remove- Returns:
trueif the ski was removed successfully, otherwisefalse, for example because the trusted SKI list did not contain the passed ski
-
setAutoAcceptMode
public void setAutoAcceptMode()
sets the node to auto-accept-mode. Authentication can be skipped that way but client has a time window for the connection, which can a preset value from 1 to 120 seconds. The default value for the window is 60 seconds. If the time window passed without any client connecting, the auto-accept-mode will be turned off.
-
requestAccessMethods
public void requestAccessMethods(ShipConnection connection)
requests the access methods for the communication partner of the specified connection. Can be used for reconnection in case the partner does- Parameters:
connection- the connection to request the access methods for
-
setConnHandler
public void setConnHandler(ConnectionHandler connHandler)
Description copied from interface:ShipInterfacesets a connection handler- Specified by:
setConnHandlerin interfaceShipInterface- Parameters:
connHandler- connectionHandler to handle all interactions with SHIP peer
-
setClientConnectedCB
public void setClientConnectedCB(ClientConnectedCallBack clientConnectedCB)
-
getServices
public javax.jmdns.ServiceInfo[] getServices()
returns an array with all detected services, including own service- Returns:
- the array with all detected services
-
shutDown
public void shutDown() throws java.io.IOExceptionshuts down service discovery, all servers and clients on the node and the node itself- Throws:
java.io.IOException- if service discovery shutdown unsuccessful
-
-