org.openbandy.net
Class ConnectionHelper
java.lang.Object
org.openbandy.net.ConnectionHelper
public class ConnectionHelper
- extends java.lang.Object
Helper class which provides static methods to read and write
message to and from a stream.
Every transmission starts with an int
which denotes
the content of the stream (e.g. ACK).
(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.
- Version:
- 0.5
- Author:
- Philipp Bolliger (philipp@bolliger.name)
Method Summary |
static Message |
readMessage(java.io.DataInputStream dataInputStream)
Tries to read a message from the input stream. |
static void |
writeMessage(Message message,
java.io.DataOutputStream dataOutputStream)
Writes the message to the output stream given |
static void |
writeStatus(int status,
java.io.DataOutputStream dataOutputStream)
Send an status (ACK | VALID_MSG | INVALID_MSG) to the output stream given |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ACK
public static final int ACK
- See Also:
- Constant Field Values
VALID_MSG
public static final int VALID_MSG
- See Also:
- Constant Field Values
INVALID_MSG
public static final int INVALID_MSG
- See Also:
- Constant Field Values
ConnectionHelper
public ConnectionHelper()
readMessage
public static Message readMessage(java.io.DataInputStream dataInputStream)
- Tries to read a message from the input stream.
- Parameters:
dataInputStream
- Input stream from which to read
- Returns:
- A message or null if nothing could be read
writeMessage
public static void writeMessage(Message message,
java.io.DataOutputStream dataOutputStream)
- Writes the message to the output stream given
- Parameters:
message
- Message to be writtendataOutputStream
- Output stream on which to write the message
writeStatus
public static void writeStatus(int status,
java.io.DataOutputStream dataOutputStream)
- Send an status (ACK | VALID_MSG | INVALID_MSG) to the output stream given
- Parameters:
status
- status to write (ACK | VALID_MSG | INVALID_MSG)dataOutputStream
- Output stream on which to write the status