public class IMBConnector extends Object implements Connector
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Connector.IMBEventType
Modifier and Type | Field and Description |
---|---|
protected Map<String,Transceiver> |
imbTransceiverMap
Registration of callback ids from IMB to OTS.
|
Constructor and Description |
---|
IMBConnector(String host,
int port,
String modelName,
int modelId,
String federation)
Construct a new connection for sending events to IMB
|
IMBConnector(TConnection connection)
Construct an IMBConnector that re-uses an existing TConnection.
|
Modifier and Type | Method and Description |
---|---|
String |
getFederation()
Return the federation name of the connection, e.g.
|
String |
getHost()
Return the host of the connection, e.g.
|
int |
getModelId()
Return the model id (owner id) of the connection, e.g.
|
String |
getModelName()
Return the model name (owner name) of the connection, e.g.
|
int |
getPort()
Return the port of the connection, e.g.
|
boolean |
postIMBMessage(String eventName,
Connector.IMBEventType imbEventType,
Object[] args)
Compose a message containing the specified objects and send it to recipients.
|
void |
register(String imbEventName,
Transceiver transceiver)
Register the transceiver as the interested party when an IMB message identified by the imbEventName is received.
|
String |
toString() |
protected Map<String,Transceiver> imbTransceiverMap
public IMBConnector(String host, int port, String modelName, int modelId, String federation) throws IMBException
host
- String; name of the IMB hubport
- int; port number of the IMB hubmodelName
- String; local model namemodelId
- int; model idfederation
- String; federation on the IMB hubIMBException
- when a connection to the IMB hub could not be establishedpublic IMBConnector(TConnection connection) throws IMBException
connection
- TConnection; the existing TConnectionIMBException
- when the connection is not connected to an IMB hubpublic void register(String imbEventName, Transceiver transceiver) throws IMBException
register
in interface Connector
imbEventName
- the IMB Event name including the federation prefix, e.g. OTS_RT.SIM_Starttransceiver
- the transceiver to handle the incoming eventIMBException
- in case the transceiver is switched to a new one for an eventpublic final boolean postIMBMessage(String eventName, Connector.IMBEventType imbEventType, Object[] args) throws IMBException
postIMBMessage
in interface Connector
eventName
- String; publicationimbEventType
- IMBEventType; one of NEW, CHANGE, or DELETEargs
- Object[]; the objects to sendIMBException
- when the event name is not a registered publicationpublic final String getHost()
public final int getPort()
public final String getModelName()
getModelName
in interface Connector
public final int getModelId()
getModelId
in interface Connector
public final String getFederation()
getFederation
in interface Connector
Copyright © 2014–2016 Delft University of Technology. All rights reserved.