public class Gateway extends java.lang.Object implements NodeConnectionServerListener, NodeConnectionListener, SddlNetworkListener, ExtendedMessageListener
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
Default incoming port to receive data from nodes
|
| Constructor and Description |
|---|
Gateway(int serverPort,
java.lang.String externalRUDPIp,
java.util.UUID gatewayId) |
Gateway(int serverPort,
java.lang.String externalRUDPIp,
java.util.UUID gatewayId,
boolean useTotalOrderGroupcast)
Initialize the Gateway from MR-UDP Server Port, External MR-UDP Port, Gateway´s ID
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the Gateway
|
void |
connected(NodeConnection remoteCon)
Used only on client side
Called when the connection is stabilished.
|
void |
disconnected(NodeConnection remoteCon)
Called when the connection is lost.
|
void |
internalException(NodeConnection nodeConnection,
java.lang.Exception exception)
Called when a internal exception occurs in the RemoteConnection
implementation.
|
void |
newMessageReceived(NodeConnection remoteCon,
ExtendedMessage message)
Called when the Gateway sends a object.
|
void |
newMessageReceived(NodeConnection nodeConnection,
Message message)
Called when the Gateway sends a object.
|
void |
newNodeConnection(NodeConnection nodeCon)
Called when a new connection is made.
|
void |
newPointOfAttachmentListReceived(NodeConnection remoteCon,
PointsOfAttachment poaList)
Called when the SDDL core sends a new points of attachment list.
|
void |
pingReceived(NodeConnection remoteCon,
Ping ping)
Called when the RemoteConnection receives a ping.
|
void |
receiveGroupAdvertisementTopic(GroupAdvertisement groupAdvertisement)
Receives a GroupAdvertisementTopic from DDS Domain and updates the node´s group membership
|
void |
receiveGroupMessageTopic(GroupMessage groupMessage)
Receives a GroupMessage Topic from DDS Domain and forward it to node(s)
|
void |
receiveLoadReportTopic(LoadReport loadReport)
Receives a LoadReport Topic from DDS Domain
|
void |
receivePingTopic(Ping ping)
Receives a Ping Topic from DDS Domain and may forward it to node(s)
|
void |
receivePrivateMessageTopic(PrivateMessage privateMessage)
Receives a PrivateMessage Topic from DDS Domain and forward it to node(s)
|
void |
receiveUnsentMessageTopic(UnsentMessage unsentMessage)
Receives a UnsentMessage Topic from DDS Domain and forward it, if applicable, to node
When Gateway receives a UnsentMessage from DDS Domain the GW checks if node is connected with it (the GW) and (if connected) forward the unsent messages to
the node
|
void |
reconnected(NodeConnection remoteCon,
java.net.SocketAddress endPoint,
boolean wasHandover,
boolean wasMandatory)
Method called to inform that the connection was broken but made again.
|
void |
sendLoadReportTopic(LoadReport loadReport)
Sends a Load Report through the DDS domain
|
void |
sendUnsentMessage(java.util.UUID nodeId,
byte[] unsentMessage)
Sends (forward) the unsent messages to the node
|
void |
startingHandover(NodeConnection remoteCon,
java.net.SocketAddress endPoint,
boolean wasMandatory)
Called when the remote connection will handover to a new Gateway.
|
void |
unsentMessages(NodeConnection remoteCon,
java.util.List<Message> unsentMessages)
Called when connection drops and there is unacked sent messages.
|
public static final int DEFAULT_PORT
public Gateway(int serverPort,
java.lang.String externalRUDPIp,
java.util.UUID gatewayId,
boolean useTotalOrderGroupcast)
throws java.io.IOException
serverPort - Incoming port to receive node data through MR-UDPexternalRUDPIp - Gateway´s IP that nodes are able to connect via MR-UDPgatewayId - Gateway´s IDuseTotalOrderGroupcast - Informs if GW should use the total order groupcastjava.io.IOException - If an I/O error occurs when opening the underlying UDP socket.public Gateway(int serverPort,
java.lang.String externalRUDPIp,
java.util.UUID gatewayId)
throws java.io.IOException
java.io.IOExceptionpublic void internalException(NodeConnection nodeConnection, java.lang.Exception exception)
NodeConnectionListenerinternalException in interface NodeConnectionListenernodeConnection - the RemoteConnection relatedexception - the Exceptionpublic void reconnected(NodeConnection remoteCon, java.net.SocketAddress endPoint, boolean wasHandover, boolean wasMandatory)
NodeConnectionListenerreconnected in interface NodeConnectionListenerremoteCon - the related remote connectionendPoint - the end point connectedwasHandover - if a handover was made, ie. if the current end point is
the different than the lastwasMandatory - is it was a mandatory handoverpublic void newNodeConnection(NodeConnection nodeCon)
newNodeConnection in interface NodeConnectionServerListenerpublic void connected(NodeConnection remoteCon)
connected in interface NodeConnectionListenerremoteCon - the RemoteConnection which the event happenedpublic void disconnected(NodeConnection remoteCon)
disconnected in interface NodeConnectionListenerremoteCon - the RemoteConnection which the event happenedpublic void newMessageReceived(NodeConnection nodeConnection, Message message)
newMessageReceived in interface NodeConnectionListenernodeConnection - the RemoteConnection which the event happenedmessage - the message just receivedpublic void unsentMessages(NodeConnection remoteCon, java.util.List<Message> unsentMessages)
unsentMessages in interface NodeConnectionListenerremoteCon - the Remote Connection related with the eventunsentMessages - a list with all unsent messagespublic void receiveGroupAdvertisementTopic(GroupAdvertisement groupAdvertisement)
groupAdvertisement - The GroupAdvertisement received from DDSpublic void receivePrivateMessageTopic(PrivateMessage privateMessage)
privateMessage - The message that should be forwarded to node(s)public void receiveUnsentMessageTopic(UnsentMessage unsentMessage)
unsentMessage - public void receivePingTopic(Ping ping)
ping - The ping receivedpublic void sendUnsentMessage(java.util.UUID nodeId,
byte[] unsentMessage)
nodeId - Vehicle´s IdunsentMessage - A byte[] with all unsent messagespublic void sendLoadReportTopic(LoadReport loadReport)
loadReport - The LoadReport to be sentpublic void close()
public void pingReceived(NodeConnection remoteCon, Ping ping)
pingReceived in interface SddlNetworkListenerremoteCon - the related remote connectionping - the ping objectpublic void newPointOfAttachmentListReceived(NodeConnection remoteCon, PointsOfAttachment poaList)
newPointOfAttachmentListReceived in interface SddlNetworkListenerremoteCon - the related remote connectionpoaList - the points of attachment listpublic void startingHandover(NodeConnection remoteCon, java.net.SocketAddress endPoint, boolean wasMandatory)
startingHandover in interface SddlNetworkListenerremoteCon - the related remote connectionendPoint - the new gateway endpointwasMandatory - true if it was a mandatory handover.public void newMessageReceived(NodeConnection remoteCon, ExtendedMessage message)
ExtendedMessageListenernewMessageReceived in interface ExtendedMessageListenerremoteCon - the RemoteConnection which the event happenedmessage - the message just receivedpublic void receiveGroupMessageTopic(GroupMessage groupMessage)
groupMessage - The message that should be forwarded to node(s)public void receiveLoadReportTopic(LoadReport loadReport)
loadReport - The LoadReport from another gateway