public class MessageCodec extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static int |
HEADER_SIZE |
static int |
MAX_BYTE |
| Constructor and Description |
|---|
MessageCodec() |
| Modifier and Type | Method and Description |
|---|---|
static Data |
createData(byte[] me,
int offset,
int length,
int ttl,
boolean protectedEntry,
PeerAddress originator) |
static Data |
decodeData(DataInput buffer,
Message message) |
static Message |
decodeHeader(org.jboss.netty.buffer.ChannelBuffer buffer,
InetAddress sender)
Decode a message header from a Netty buffer
|
static void |
decodePayload(Message.Content content,
org.jboss.netty.buffer.ChannelBuffer buffer,
Message message)
Decodes the payload from a Netty buffer in a big switch
|
static PublicKey |
decodePublicKey(DataInput buffer,
byte[] receivedRawPublicKey) |
static int |
encodeData(Collection<DataOutput> result,
DataOutputFactory factory,
Message message,
Data data) |
static org.jboss.netty.buffer.ChannelBuffer |
encodeHeader(org.jboss.netty.buffer.ChannelBuffer buffer,
Message message)
The format looks as follows:
32bit p2p version - 32bit id - 4bit message type - 4bit message name -
160bit sender id - 16bit tcp port - 16bit udp port - 160bit recipient id
- 32bit message length - 16bit (4x4)content type - 8bit network address
information - 32bit network information.
|
static void |
encodePayload(Message message,
List<org.jboss.netty.buffer.ChannelBuffer> payloadBuffers)
Encode payload
|
static void |
encodeSecurity(Message message,
List<org.jboss.netty.buffer.ChannelBuffer> buffers) |
public static final byte[] EMPTY_BYTE_ARRAY
public static final int MAX_BYTE
public static final int HEADER_SIZE
public static org.jboss.netty.buffer.ChannelBuffer encodeHeader(org.jboss.netty.buffer.ChannelBuffer buffer,
Message message)
buffer - The Netty buffer to fillmessage - The message with the header that will be serializedpublic static void encodePayload(Message message, List<org.jboss.netty.buffer.ChannelBuffer> payloadBuffers) throws InvalidKeyException, SignatureException, NoSuchAlgorithmException
buffer - The Netty buffer to fillmessage - The message which contains the payloadNoSuchAlgorithmExceptionSignatureExceptionInvalidKeyExceptionpublic static void encodeSecurity(Message message, List<org.jboss.netty.buffer.ChannelBuffer> buffers) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException
public static int encodeData(Collection<DataOutput> result, DataOutputFactory factory, Message message, Data data)
public static Message decodeHeader(org.jboss.netty.buffer.ChannelBuffer buffer, InetAddress sender) throws DecoderException
buffer - The buffer to decode fromsender - The sender of the packet, which has been set in the socket
classDecoderExceptionpublic static void decodePayload(Message.Content content, org.jboss.netty.buffer.ChannelBuffer buffer, Message message) throws InvalidKeyException, SignatureException, NoSuchAlgorithmException, InvalidKeySpecException, IOException
content - The content typebuffer - The buffer to read frommessage - The message to store the resultsIndexOutOfBoundsException - If a buffer is read beyond its limitsNoSuchAlgorithmExceptionSignatureExceptionInvalidKeyExceptionInvalidKeySpecExceptionInvalidKeySpecExceptionIOExceptionASN1ExceptionUnsupportedEncodingException - If UTF-8 is not therepublic static Data decodeData(DataInput buffer, Message message) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, UnknownHostException
public static Data createData(byte[] me, int offset, int length, int ttl, boolean protectedEntry, PeerAddress originator)
public static PublicKey decodePublicKey(DataInput buffer, byte[] receivedRawPublicKey) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException
Copyright © 2011. All Rights Reserved.