| java.lang.Object com.sun.midp.jsr82emul.Messenger
Messenger | final public class Messenger (Code) | | Represents JSR 82 emulation protocol, namely messages and codes recognized
by emulation client and/or server.
It is not a part of JSR 82 implementation and is only used within JSR 82
emulation mode. The emulation mode allows running tets without real native
Bluetooth libraries or hardware.
Emulation server and client communicate thru a socket by means of sending
data packets of the following format:
1 byte |
1 byte |
as defined by the previous field |
packet type code |
length of information in bytes |
information bytes |
|
Field Summary | |
final public static byte | CONNECT_TO_SERVICE Request for service connection. | final public static byte | DONE Notification that client does not require server any more. | final public static String | ENCODING Keeps encoding for messages. | final public static byte | ERROR Responce code that identifies a failure. | final public static byte | INQUIRY_COMPLETED Respond on inquiry completion. | final public static byte | REGISTERED Successfull registration response. | final public static byte | REGISTER_DEVICE Device registration request code. | final public static byte | REGISTER_SERVICE Code for starting advertising service in the ether. | final public static byte | SERVICE_AT Respond that provides service connection details. | final public static byte | SPECIFIC_MESSAGE Code for specific messages that are only recognized by specific
handlers at server side. | final public static byte | START_INQUIRY Request for inquiry start. | final public static byte | UNREGISTER_SERVICE Code for unregistering service. | final public static byte | UPDATE_DEVICE_STATE Command to update device state that includes discoverable mode and
device class. |
Constructor Summary | |
public | Messenger() Constructs an instance. |
Method Summary | |
public byte[] | getBytes() Provides bytes read by the last receive() invocation. | public byte | getCode() Provides code read by the last receive() invocation. | public int | getInt() Retrieves integer represented by bytes read by the last
receive() invocation. | public String | getMessage() Provides message read by the last receive() invocation. | public void | receive(InputStream in) Receives a packet from input stream given saving retrieved data in
code and message . | public void | send(OutputStream out, byte code, String message) Forms a packet with given code and message and sends it to given output
stream. | public void | sendBytes(OutputStream out, byte code, byte[] info) Forms a packet with given code and bytes to send and sends it to
given output stream. | public void | sendInt(OutputStream out, byte code, int value) Forms a packet with given code and bytes that represent given integer,
then sends it to given output stream. |
CONNECT_TO_SERVICE | final public static byte CONNECT_TO_SERVICE(Code) | | Request for service connection.
|
DONE | final public static byte DONE(Code) | | Notification that client does not require server any more.
|
ENCODING | final public static String ENCODING(Code) | | Keeps encoding for messages.
|
ERROR | final public static byte ERROR(Code) | | Responce code that identifies a failure.
|
INQUIRY_COMPLETED | final public static byte INQUIRY_COMPLETED(Code) | | Respond on inquiry completion.
|
REGISTERED | final public static byte REGISTERED(Code) | | Successfull registration response.
|
REGISTER_DEVICE | final public static byte REGISTER_DEVICE(Code) | | Device registration request code.
|
REGISTER_SERVICE | final public static byte REGISTER_SERVICE(Code) | | Code for starting advertising service in the ether.
|
SERVICE_AT | final public static byte SERVICE_AT(Code) | | Respond that provides service connection details.
|
SPECIFIC_MESSAGE | final public static byte SPECIFIC_MESSAGE(Code) | | Code for specific messages that are only recognized by specific
handlers at server side.
|
START_INQUIRY | final public static byte START_INQUIRY(Code) | | Request for inquiry start.
|
UNREGISTER_SERVICE | final public static byte UNREGISTER_SERVICE(Code) | | Code for unregistering service.
|
UPDATE_DEVICE_STATE | final public static byte UPDATE_DEVICE_STATE(Code) | | Command to update device state that includes discoverable mode and
device class.
|
Messenger | public Messenger()(Code) | | Constructs an instance. Always use different instances for different
clients/servers to make sure data stored in message and
code is appropriate.
|
getBytes | public byte[] getBytes()(Code) | | Provides bytes read by the last receive() invocation.
bytes received last time. |
getCode | public byte getCode()(Code) | | Provides code read by the last receive() invocation.
the code received last time, -1 if there is no valid value. |
getInt | public int getInt()(Code) | | Retrieves integer represented by bytes read by the last
receive() invocation. Throws IllegalArgument exception
if those bytes do not represent an integer.
integer represented by bytes received last time. exception: EmulationException - if no valid value read |
getMessage | public String getMessage()(Code) | | Provides message read by the last receive() invocation.
string message received last time. exception: EmulationException - if no valid value read |
receive | public void receive(InputStream in) throws IOException(Code) | | Receives a packet from input stream given saving retrieved data in
code and message .
Parameters: in - the input stream to read from. exception: IOException - if one is issued by in methods. |
send | public void send(OutputStream out, byte code, String message) throws IOException(Code) | | Forms a packet with given code and message and sends it to given output
stream.
Parameters: out - the output stream to send to. Parameters: code - the code to send. Parameters: message - the message to send. exception: IOException - if one is issued by out methods. |
sendBytes | public void sendBytes(OutputStream out, byte code, byte[] info) throws IOException(Code) | | Forms a packet with given code and bytes to send and sends it to
given output stream.
Parameters: out - the output stream to send to Parameters: code - the code to send Parameters: info - byte array to be sent entirely exception: IOException - if one is issued by out methods. |
sendInt | public void sendInt(OutputStream out, byte code, int value) throws IOException(Code) | | Forms a packet with given code and bytes that represent given integer,
then sends it to given output stream.
Parameters: out - the output stream to send to Parameters: code - the code to send Parameters: value - integer to send exception: IOException - if one is issued by out methods. |
|
|