public class SimpleSgsProtocolConstants extends Object
A protocol message is constructed as follows:
A ByteArray
is encoded in a context dependent fashion. If the
ByteArray is the only content, or if the ByteArray is the last piece of
content (that is, if the length of the ByteArray can be determined by the
payload length and the length of what has come before), the ByteArray is
encoded as
A String
is encoded as follows:
DataInput
The total length of a message must not be greater than 65535 bytes; given the header information this means that the payload of a message cannot be greater than 65532 bytes. If a message larger than this must be sent, it is the responsibility of the sender to break the message into pieces and of the receiver to re-assemble those pieces.
Behavior not specified in this document is left as an implementation decision for the particular client and server. Information on the implementation characteristics of the RedDwarf server can be found in the overview for the implementation.
Modifier and Type | Field and Description |
---|---|
static byte |
CHANNEL_JOIN
Channel join.
|
static byte |
CHANNEL_LEAVE
Channel leave.
|
static byte |
CHANNEL_MESSAGE
Channel message.
|
static byte |
LOGIN_FAILURE
Login failure.
|
static byte |
LOGIN_REDIRECT
Login redirect.
|
static byte |
LOGIN_REQUEST
Login request from a client to a server.
|
static byte |
LOGIN_SUCCESS
Login success.
|
static byte |
LOGOUT_REQUEST
Logout request from a client to a server.
|
static byte |
LOGOUT_SUCCESS
Logout success.
|
static int |
MAX_MESSAGE_LENGTH
The maximum length of a protocol message:
65535 bytes.
|
static int |
MAX_PAYLOAD_LENGTH
The maximum payload length:
65532 bytes.
|
static byte |
RECONNECT_FAILURE
Reconnect failure.
|
static byte |
RECONNECT_REQUEST
Reconnection request.
|
static byte |
RECONNECT_SUCCESS
Reconnect success.
|
static byte |
RELOCATE_FAILURE
Relocate failure.
|
static byte |
RELOCATE_NOTIFICATION
Relocate session notification.
|
static byte |
RELOCATE_REQUEST
Relocation request.
|
static byte |
RELOCATE_SUCCESS
Relocation success.
|
static byte |
RESUME_MESSAGES
Resume messages notification.
|
static byte |
SESSION_MESSAGE
Session message.
|
static byte |
SUSPEND_MESSAGES
Suspend messages notification.
|
static byte |
SUSPEND_MESSAGES_COMPLETE
Acknowledgment of
SUSPEND_MESSAGES notification. |
static byte |
VERSION
The version number, currently
0x05 . |
Modifier | Constructor and Description |
---|---|
protected |
SimpleSgsProtocolConstants()
This class should not be instantiated.
|
public static final int MAX_MESSAGE_LENGTH
public static final int MAX_PAYLOAD_LENGTH
public static final byte VERSION
0x05
.public static final byte LOGIN_REQUEST
0x10
protocol version
will be checked by the server to insure that
the client and server are using the same protocol or versions of the
protocol that are compatible. If the server determines that the protocol
version used by the sender and the protocol version or versions required
by the server are not compatible, the server will disconnect the client.
In cases where the protocols being used are not compatible, no other
communication between the client and the server is guaranteed to be
understood.
The name
and password
strings are passed to the server's
authentication mechanism. After the server processes the login request,
the server sends one of the following acknowledgments to the client:
LOGIN_SUCCESS
, if user authentication succeeds and
invoking the loggedIn
' method on the application's
AppListener
with the user's ClientSession
returns a
non-null, serializable ClientSessionListener
;
LOGIN_REDIRECT
, if user authentication succeeds, but the
server requests that the client redirect the login request to another
node; or
LOGIN_FAILURE
, if user authentication fails, or if the
user is already logged in and the server is configured to reject new
logins for the same user, or if invoking the loggedIn
method on
the application's AppListener
with the user's
ClientSession
returns a null, or non-serializable
ClientSessionListener
or the method does not complete
successfully.
If a client is currently logged in, the result of receiving a LOGIN_REQUEST is not defined by the protocol, but is an implementation-dependent detail of the server.
public static final byte LOGIN_SUCCESS
LOGIN_REQUEST
.
0x11
reconnectionKey
is an opaque reference that can be held by
the client for use in case the client is disconnected and wishes to
reconnect to the server with the same identity using a
RECONNECT_REQUEST
.public static final byte LOGIN_FAILURE
LOGIN_REQUEST
.
0x12
LOGIN_REQUEST
for some reason, for example
public static final byte LOGIN_REDIRECT
LOGIN_REQUEST
.
0x13
LOGIN_REQUEST
was sent to another node. The client receiving
this request should shut down the connection to the original node and
establish a connection to the node indicated by the hostname
and
port
in the payload. The client should then attempt to log in to
the node to which it has been redirected by sending a
LOGIN_REQUEST
to that node.public static final byte SUSPEND_MESSAGES
0x14
This message notifies a client to suspend sending messages to the
server until it receives further instruction (such as RELOCATE_NOTIFICATION
or RESUME_MESSAGES
). The client
should send the acknowledgment SUSPEND_MESSAGES_COMPLETE
to
the server when it has suspended sending messages. After the server
sends a SUSPEND_MESSAGES
notification to the client, the
server may decide to drop messages from the client if it does not
receive the SUSPEND_MESSAGES_COMPLETE
acknowledgment in a
timely fashion.
This opcode was introduced in protocol version 0x05
.
public static final byte SUSPEND_MESSAGES_COMPLETE
SUSPEND_MESSAGES
notification. Client to
server notification.
0x15
This message notifies the server that the client has received the
SUSPEND_MESSAGES
notification. Any messages received by the
server after this notification will be dropped, unless the server
has instructed the client to either resume messages or relocate its
client session to another node.
This opcode was introduced in protocol version 0x05
.
public static final byte RESUME_MESSAGES
0x16
This message notifies the client that it can resume sending messages to the server.
This opcode was introduced in protocol version 0x05
.
public static final byte RELOCATE_NOTIFICATION
0x17
hostname
and port
in the payload. The client should then attempt to reestablish
the client session with the server (without logging in) using the
relocationKey
specified in the payload.
This opcode was introduced in protocol version 0x05
.
public static final byte RELOCATE_REQUEST
0x18
relocationKey
must match the one that the client received in the
previous RELOCATE_NOTIFICATION
message. If relocation is
successful, the server acknowledges the request with a RELOCATE_SUCCESS
message containing a reconnectionKey
for
reconnecting to the server. If relocation is not successful, a
RELOCATE_FAILURE
message is sent to the client. If the
client receives a RELOCATE_FAILURE
message, the client
should disconnect from the server.
This opcode was introduced in protocol version 0x05
.
public static final byte RELOCATE_SUCCESS
RELOCATE_REQUEST
.
0x19
reconnectionKey
is an opaque reference that can be held by
the client for use in case the client is disconnected and wishes to
reconnect to the server with the same identity using a
RECONNECT_REQUEST
.
This opcode was introduced in protocol version 0x05
.
public static final byte RELOCATE_FAILURE
RELOCATE_REQUEST
.
0x1a
RELOCATE_REQUEST
for some reason, for example
This opcode was introduced in protocol version 0x05
.
public static final byte RECONNECT_REQUEST
0x20
reconnectionKey
must match
the one that the client received in the previous LOGIN_SUCCESS
or RECONNECT_SUCCESS
message (if reconnection was performed
subsequent to login). If reconnection is successful, the server
acknowledges the request with a RECONNECT_SUCCESS
message
containing a new reconnectionKey
. If reconnection is not
successful, a RECONNECT_FAILURE
message is sent to the client.
If the client receives a RECONNECT_FAILURE
message, the client
should disconnect from the server.public static final byte RECONNECT_SUCCESS
RECONNECT_REQUEST
. 0x21
RECONNECT_REQUEST
has been successful. The
message will include a reconnectionKey
that can be used in a
subsequent reconnect requests from the client. Reciept of this message
indicates that the client session has been re-established.public static final byte RECONNECT_FAILURE
RECONNECT_REQUEST
.
0x22
public static final byte SESSION_MESSAGE
0x30
public static final byte LOGOUT_REQUEST
0x40
LOGIN_REQUEST
) sent by the client after sending this
message will be ignored, and any message will need to be sent on a new
connection to the server.public static final byte LOGOUT_SUCCESS
LOGOUT_REQUEST
.
0x41
LOGOUT_REQUEST
has been received and that the client has been
logged out of the current session. On receipt of this message, the client
should shut down any networking resources that are used to communicate
with the server.public static final byte CHANNEL_JOIN
0x50
channel
name
and channel ID
contained in the message.public static final byte CHANNEL_LEAVE
0x51
channel ID
. The client can no longer send messages on the channel.public static final byte CHANNEL_MESSAGE
channel ID
size and two bytes (the size of the unsigned short indicating
the channel Id
size). Larger messages require fragmentation and
reassembly above this protocol layer.
0x52
Copyright © 2013. All Rights Reserved.