public class TcpBridge
extends java.lang.Object
Constructor and Description |
---|
TcpBridge(java.lang.String relay,
int port,
java.lang.String relayID,
java.lang.String bridgeName)
Creates a TcpBridge instance for communications between agents.
|
TcpBridge(java.lang.String sessionID,
java.lang.String bridgeName)
Creates a TcpBridge instance for communications between agents.
|
Modifier and Type | Method and Description |
---|---|
void |
addTcpBridgeListener(TcpBridgeListener listener)
Registers a TcpBridgeListener that pipes the data and reports connection state changes.
|
java.util.ArrayList<java.lang.String> |
connectToRelay()
Same as connectToRelay(timeout), but waits infinitely for connection.
|
java.util.ArrayList<java.lang.String> |
connectToRelay(int timeout)
Connects to the tunneling relay given sessionID and timeout.
|
void |
disconnect()
Disconnects the bridge from the relay.
|
java.lang.String |
getBridgeName()
Returns the requested bridge nickname.
|
long |
getClockTime()
Returns current time of internal clock synchronized with the relay's clock (in ms).
|
java.lang.String |
getPersonalName()
Returns the nickname attributed by the relay after successful connection.
|
int |
getPort()
Returns the IP port number used by the relay server.
|
java.lang.String |
getRelay()
Returns the IP address of the relay server.
|
TcpNode |
getTcpNode()
Returns the TcpNode reference responsible for the connection.
|
java.lang.String |
getVersion()
Returns current version information of TcpJLib.
|
boolean |
isConnected()
Checks if the bridge is connected to the relay.
|
void |
send(java.lang.String source,
java.lang.String destination,
int... data)
Sends data to destination including the given source indicator.
|
void |
sendCommand(java.lang.String source,
java.lang.String destination,
int command,
int... data)
Sends data to destination including the given source indicator.
|
void |
sendCommandToGroup(java.lang.String source,
java.util.ArrayList<java.lang.String> destinations,
int delay,
int command,
int... data)
Same as sendCommand(), but sends the data to all members of the given list.
|
void |
sendRelayRequest(java.lang.String request)
Sends a request to the relay.
|
int |
sendSynchRequest()
Sends a clock synchronization request on a new TCP/IP channel
(not influenced by the current traffic between the relay and the node).
|
void |
sendToGroup(java.lang.String source,
java.util.ArrayList<java.lang.String> destinations,
int delay,
int... data)
Same as send(), but sends the data to all members of the given list.
|
public TcpBridge(java.lang.String relay, int port, java.lang.String relayID, java.lang.String bridgeName)
public TcpBridge(java.lang.String sessionID, java.lang.String bridgeName)
public java.util.ArrayList<java.lang.String> connectToRelay(int timeout)
timeout
- in ms; if <=0 waits infinitely for connectionpublic java.util.ArrayList<java.lang.String> connectToRelay()
public void disconnect()
public void send(java.lang.String source, java.lang.String destination, int... data)
source
- the nickname of an agent that indicates the source of the datadestination
- the nickname of a agent to whom the data will be sentdata
- an integer array or any number of integerspublic void sendCommand(java.lang.String source, java.lang.String destination, int command, int... data)
source
- the nickname of an agent that indicates the source of the datadestination
- the nickname of a agent to whom the data will be sentcommand
- an integer that is interpreted as command tagdata
- an integer array or any number of integerspublic void sendToGroup(java.lang.String source, java.util.ArrayList<java.lang.String> destinations, int delay, int... data)
source
- the nickname of an agent that indicates the source of the datadestinations
- the list of nicknames of the agents to whom the data will be sentdelay
- the delay in ms between successive data sending to agentsdata
- an integer array or any number of integerspublic void sendCommandToGroup(java.lang.String source, java.util.ArrayList<java.lang.String> destinations, int delay, int command, int... data)
source
- the nickname of an agent that indicates the source of the datadestinations
- the nickname of a agent to whom the data will be sentdelay
- the delay in ms between successive data sending to agentscommand
- an integer that is interpreted as command tagdata
- an integer array or any number of integerspublic void sendRelayRequest(java.lang.String request)
request
- a string representing the request as
defined as static in class TcpNodepublic void addTcpBridgeListener(TcpBridgeListener listener)
listener
- the listener to registerpublic boolean isConnected()
public java.lang.String getRelay()
public int getPort()
public java.lang.String getBridgeName()
public java.lang.String getPersonalName()
public java.lang.String getVersion()
public long getClockTime()
public int sendSynchRequest()
public TcpNode getTcpNode()