|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.juoserver.protocol.AbstractMessage
public abstract class AbstractMessage
Base class for messages.
Messages can be sent by the client or the server, or both (e.g.ClientVersion
).
Messages sent by clients (e.g. CharacterSelect
) should:
Decodable
,CharacterList
) should:
encode()
method,isCompressed()
method.ControllerImpl
class and thus letting it
reply to the client message with a server message.
Field Summary | |
---|---|
protected static int |
NO_CODE
|
static String |
UTF8
|
Constructor Summary | |
---|---|
protected |
AbstractMessage(int code,
int length)
Builds a message from the code that identifies it. |
Method Summary | |
---|---|
ByteBuffer |
encode()
Encodes this message into a byte array packet. |
abstract boolean |
equals(Object obj)
|
int |
getCode()
|
int |
getLength()
|
String |
getName()
|
abstract int |
hashCode()
|
boolean |
isCompressed()
Default value is true. |
protected ByteBuffer |
wrapContents(byte[] contents)
Returns a new ByteBuffer wrapping the packet contents, excluding
the first byte (the packet code). |
protected ByteBuffer |
wrapContents(int fromIndexInclusive,
byte[] contents)
Returns a new ByteBuffer wrapping the packet contents, starting
from the specified index, inclusive. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String UTF8
protected static final int NO_CODE
Constructor Detail |
---|
protected AbstractMessage(int code, int length)
code
- message's identification codeMethod Detail |
---|
public ByteBuffer encode()
Message
encode
in interface Message
public boolean isCompressed()
isCompressed
in interface Message
true
if and only if this message should be compressed when sent by the serverpublic final int getCode()
getCode
in interface Message
public final int getLength()
getLength
in interface Message
public abstract int hashCode()
hashCode
in class Object
public abstract boolean equals(Object obj)
equals
in class Object
public final String getName()
protected final ByteBuffer wrapContents(byte[] contents)
ByteBuffer
wrapping the packet contents, excluding
the first byte (the packet code).
Note that the returned buffer will be backed up by the provided array,
therefore modifications to the buffer will change the array and vice
versa.
contents
- packet contents
ByteBuffer
wrapping the packet contents,
excluding the first byte (the packet code)wrapContents(int, byte[])
protected final ByteBuffer wrapContents(int fromIndexInclusive, byte[] contents)
ByteBuffer
wrapping the packet contents, starting
from the specified index, inclusive.
Note that the returned buffer will be backed up by the provided array,
therefore modifications to the buffer will change the array and vice
versa.
fromIndexInclusive
- starting index where to start reading the
contents, inclusivecontents
- packet contents
ByteBuffer
wrapping the packet contents,
excluding the first byte (the packet code)ByteBuffer.wrap(byte[], int, int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |