public class JadexRelayExample
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ADDRESS
The relay server address.
|
static byte |
MSGTYPE_DEFAULT
The default message type: followed by length (int as 4 bytes) and arbitrary message content from some sender.
|
static byte |
MSGTYPE_PING
The ping message type sent by server to verify if connection is alive (just the type byte and no content).
|
protected static byte[] |
RESPONSE_BUF
A buffer for reading response data (ignored but needs to be read for connection to be reusable).
|
| Constructor and Description |
|---|
JadexRelayExample() |
| Modifier and Type | Method and Description |
|---|---|
static int |
bytesToInt(byte[] buffer)
Convert bytes to an integer.
|
static void |
connect(java.lang.String id)
Start a new thread and connect to the relay server.
|
static void |
deliverMessage(byte[] rawmsg)
Called whenever a message is received.
|
static byte[] |
intToBytes(int val)
Convert an integer to bytes.
|
static void |
main(java.lang.String[] args)
Main method for testing.
|
static void |
send(java.lang.String id,
byte[] data)
Send a message.
|
public static final java.lang.String ADDRESS
public static final byte MSGTYPE_DEFAULT
public static final byte MSGTYPE_PING
protected static final byte[] RESPONSE_BUF
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exceptionpublic static void deliverMessage(byte[] rawmsg)
public static void connect(java.lang.String id)
throws java.lang.Exception
java.lang.Exceptionpublic static void send(java.lang.String id,
byte[] data)
throws java.io.IOException
java.io.IOExceptionpublic static int bytesToInt(byte[] buffer)
public static byte[] intToBytes(int val)