Robot Core Documentation
|
The Network class handles network connections. More...
Classes | |
interface | NetworkReceiver |
The NetworkReceiver interface provides a callback for received data on a network connection. More... | |
Public Member Functions | |
void | connect (NetworkReceiver receiver, String host, int port, int retryTime) |
void | connect (NetworkReceiver receiver, String host, int port) |
void | sendMessage (String message) |
void | listen (NetworkReceiver receiver, int port) |
void | closeConnection () |
The Network class handles network connections.
This class handles network connections. You can choose to either connect to a specified IP address or to listen for incoming connections of a specified port.
In either case, a two way connection is established. The receiver end of the connection is handled via a separate thread and there is a callback provided when data is received.
The transmit side runs in whatever thread the calling function is using.
void robotCore.Network.closeConnection | ( | ) |
This function closes the connection.
void robotCore.Network.connect | ( | NetworkReceiver | receiver, |
String | host, | ||
int | port ) |
This function attempts to connect to the specified host. If the connection fails, it will retry the connection. If the connection succeeds, a thread will be started that will retrieve any data sent over the connection and pass that data on to a handler via the NetworkReceiver interface.
It uses the default retry time of 5000 ms.
receiver | - Specifies class that will receive data from the connection |
host | - Specifies the host IP address |
port | - Specifies the host port number |
void robotCore.Network.connect | ( | NetworkReceiver | receiver, |
String | host, | ||
int | port, | ||
int | retryTime ) |
This function attempts to connect to the specified host. If the connection fails, it will retry the connection. If the connection succeeds, a thread will be started that will retrieve any data sent over the connection and pass that data on to a handler via the NetworkReceiver interface.
receiver | - Specifies class that will receive data from the connection |
host | - Specifies the host IP address |
port | - Specifies the host port number |
retryTime | - Specifies the amount of time in milliseconds to retry failed connections |
void robotCore.Network.listen | ( | NetworkReceiver | receiver, |
int | port ) |
This function will start a new thread which will listen on the specified port for an incoming connection. Once the connection is made, it will retrieve any data sent over the connection (using the created thread) and pass that data on to a handler via the NetworkReceiver interface.
receiver | - Specifies class that will receive data from the connection |
port | - Specifies the port to listen on |
void robotCore.Network.sendMessage | ( | String | message | ) |
This function sends the specified string via the connection if the connection is open.
message | - Specifies message to be sent |