|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object triptracker.core.Protocol
public class Protocol
The Protocol class works by being a common place where both the server and client can obtain information in order to conform to the protocol.
Field Summary | |
---|---|
static int |
AUTH_FAIL
Authentication failed. |
static int |
AUTH_OK
Authentication successful. |
static int |
COORD_ADD
New coordinate added. |
static int |
COORD_BUFFER_ADD
Add a bundle of coordinates. |
static String |
DELIMITER
Message field delimiter. |
static String |
HOST
Default host address. |
static int |
MAKE_ROUTE
Make a new route. |
static int |
MAPCLIENT
Client is a coordinate reciever/sink. |
static String |
NEWLINE
The newline character separating each message. |
static int |
PORTNR
Default protocol port number. |
static int |
QUIT
Client wants to terminate the connection. |
static int |
REALTIME
Realtime state has changed. |
static int |
ROUTE_GET
Get all coodinates for spesific route. |
static int |
ROUTE_LOCK
Lock/unlock a route. |
static int |
SENDCLIENT
Client is a coordinate sender/source. |
static int |
SET_ROUTE
Set active route. |
static int |
USER_GET
Gets spesific user |
static int |
USERS_GET
Get list of all users. |
static int |
VIEW_ROUTES
Request for a list of all routes for a spesific user. |
static int |
ZIP_BUFFERSIZE
Default compressed buffersize. |
Constructor Summary | |
---|---|
Protocol()
|
Method Summary | |
---|---|
static String |
makeMsg(Object... message)
Builds a message by adding DELIMITER between each message part
and putting NEWLINE at the end. |
static StringBuilder |
makeMsg(StringBuilder builder,
Object... message)
Builds a message by adding DELIMITER between each message part
and putting NEWLINE at the end. |
static StringBuilder |
makeMsg(String msgDelim,
StringBuilder builder,
Object... message)
Builds a message by adding DELIMITER between each message part
and putting msgDelim at the end. |
static void |
send(OutputStream out,
boolean flush,
Object... message)
Send a message with the specified stream. |
static void |
send(OutputStream out,
Object... message)
Sends a message with the specified stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NEWLINE
println()
in Java is different
on both Windows, Linux/Unix and Mac. Although readLine()
in
Java automatically handles all newline types, other languages probably
won't.
public static final String DELIMITER
public static final int PORTNR
public static final String HOST
public static final int ZIP_BUFFERSIZE
public static final int SENDCLIENT
public static final int MAPCLIENT
public static final int QUIT
public static final int AUTH_FAIL
public static final int AUTH_OK
public static final int COORD_ADD
Syntax: <latitude>, <longitude>, <dateTime>
The format of dateTime is "yyyy-MM-dd hh:mm:ss".
public static final int COORD_BUFFER_ADD
Syntax: <zipped string of coordinates>
public static final int MAKE_ROUTE
Syntax: <description>
public static final int SET_ROUTE
Syntax: <routeId>
public static final int VIEW_ROUTES
Syntax: <username>
public static final int USERS_GET
public static final int ROUTE_GET
Syntax: <routeId>
public static final int ROUTE_LOCK
Syntax: <routeId>
public static final int REALTIME
Syntax: <enabled>
enabled: true if realtime is starting, and false if realtime stopped
public static final int USER_GET
Constructor Detail |
---|
public Protocol()
Method Detail |
---|
public static void send(OutputStream out, boolean flush, Object... message) throws IOException
DELIMITER
character and the whole message
will be terminated by the NEWLINE
string.
out
- output stream to sent message toflush
- if true
flush the output stream and force any
buffered output bytes to be written out after the message has
been written to the streammessage
- message to send
IOException
- on failed sendpublic static void send(OutputStream out, Object... message) throws IOException
send(stream, false, message)
.
out
- output stream to sent message tomessage
- message to send
IOException
- on failed sendsend(OutputStream, boolean, Object[])
public static String makeMsg(Object... message)
DELIMITER
between each message part
and putting NEWLINE
at the end.
message
- parts to delimit
makeMsg(String, StringBuilder, Object[])
public static StringBuilder makeMsg(String msgDelim, StringBuilder builder, Object... message)
DELIMITER
between each message part
and putting msgDelim
at the end. All messages will be
appended to the existing builder
, or if builder
is null
then a new StringBuilder
will be created.
msgDelim
- string to put at the end of the messagebuilder
- StringBuilder to use for adding data, if null then a new
string builder will be createdmessage
- parts to delimit
NEWLINE
.public static StringBuilder makeMsg(StringBuilder builder, Object... message)
DELIMITER
between each message part
and putting NEWLINE
at the end. All messages will be appended to
the existing builder
, or if builder
is
null
then a new StringBuilder
will be created.
builder
- StringBuilder to use for adding data, if null then a new
string builder will be createdmessage
- parts to delimit
NEWLINE
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |