public class Message extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Message.Content
8 x 4 bit.
|
static class |
Message.Type
1 x 4 bit.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
CONTENT_TYPE_LENGTH |
| Constructor and Description |
|---|
Message()
Creates message with a random ID.
|
| Modifier and Type | Method and Description |
|---|---|
SimpleBloomFilter<Number160> |
bloomFilter(int index) |
Message |
bloomFilter(SimpleBloomFilter<Number160> bloomFilter) |
List<SimpleBloomFilter<Number160>> |
bloomFilterList() |
Message |
buffer(Buffer byteBuf) |
Buffer |
buffer(int index) |
List<Buffer> |
bufferList() |
byte |
command()
Command of the message, such as GET, PING, etc.
|
Message |
command(byte command)
Command of the message, such as GET, PING, etc.
|
Queue<MessageContentIndex> |
contentReferences() |
Message |
contentType(int index,
Message.Content contentType)
Sets or replaces the content type at a specific index.
|
Message |
contentType(Message.Content contentType)
Convenient method to set content type.
|
Message.Content[] |
contentTypes()
Return content types.
|
Message |
contentTypes(Message.Content[] contentTypes)
Used for deserialization.
|
DataMap |
dataMap(int index) |
List<DataMap> |
dataMapList() |
boolean |
hasContent() |
Message |
hasContent(boolean content) |
Integer |
intAt(int index) |
List<Integer> |
intList() |
Message |
intValue(int integer) |
boolean |
isDone() |
boolean |
isError() |
static boolean |
isError(Message.Type type) |
boolean |
isFireAndForget() |
boolean |
isKeepAlive() |
boolean |
isNotOk() |
boolean |
isOk() |
boolean |
isRequest() |
boolean |
isSign() |
boolean |
isStreaming() |
boolean |
isUdp() |
Message |
keepAlive(boolean isKeepAlive) |
Number160 |
key(int index) |
Message |
key(Number160 key) |
KeyCollection |
keyCollection(int index) |
Message |
keyCollection(KeyCollection key) |
List<KeyCollection> |
keyCollectionList() |
List<Number160> |
keyList() |
KeyMap640Keys |
keyMap640Keys(int index) |
Message |
keyMap640Keys(KeyMap640Keys keyMap) |
List<KeyMap640Keys> |
keyMap640KeysList() |
KeyMapByte |
keyMapByte(int index) |
Message |
keyMapByte(KeyMapByte keyMap) |
List<KeyMapByte> |
keyMapByteList() |
Long |
longAt(int index) |
List<Long> |
longList() |
Message |
longValue(long long0) |
int |
messageId()
Randomly generated message ID.
|
Message |
messageId(int messageId)
For deserialization, we need to set the id.
|
NeighborSet |
neighborsSet(int index) |
Message |
neighborsSet(NeighborSet neighborSet) |
List<NeighborSet> |
neighborsSetList() |
int |
options() |
Message |
options(int options) |
List<PeerSocketAddress> |
peerSocketAddresses() |
Message |
peerSocketAddresses(Collection<PeerSocketAddress> peerSocketAddresses) |
Message |
presetContentTypes(boolean presetContentTypes)
If we are setting values from the decoder, then the content type is already set.
|
PrivateKey |
privateKey() |
PublicKey |
publicKey(int index) |
Message |
publicKey(PublicKey publicKey) |
Message |
publicKeyAndSign(KeyPair keyPair) |
List<PublicKey> |
publicKeyList() |
SignatureCodec |
receivedSignature() |
Message |
receivedSignature(SignatureCodec signatureEncode) |
PeerAddress |
recipient()
The ID of the recipient.
|
Message |
recipient(PeerAddress recipient)
Set the ID of the recipient.
|
PeerAddress |
recipientRelay() |
Message |
recipientRelay(PeerAddress recipientRelay) |
InetSocketAddress |
recipientSocket() |
Message |
recipientSocket(InetSocketAddress recipientSocket)
Store the recipient of the packet.
|
void |
restoreBuffers()
Restores all buffers such that they can be re-read (e.g.
|
void |
restoreContentReferences()
Restore the content references if only the content types array is
present.
|
PeerAddress |
sender()
The ID of the sender.
|
Message |
sender(PeerAddress sender)
The ID of the sender.
|
InetSocketAddress |
senderSocket() |
Message |
senderSocket(InetSocketAddress senderSocket)
Store the sender of the packet.
|
Message |
setDataMap(DataMap dataMap) |
Message |
setDone()
Set done to true if message decoding or encoding is done.
|
Message |
setDone(boolean done) |
Message |
setHintSign()
Set if we have a signed message.
|
Message |
setVerified() |
Message |
streaming() |
Message |
streaming(boolean streaming) |
String |
toString() |
TrackerData |
trackerData(int index) |
Message |
trackerData(TrackerData trackerData) |
List<TrackerData> |
trackerDataList() |
Message.Type |
type()
Determines if its a request or command reply, and what kind of reply (error, warning states).
|
Message |
type(Message.Type type)
Set the message type.
|
Message |
udp(boolean udp) |
boolean |
verified() |
Message |
verified(boolean verified) |
int |
version()
Returns the version, which is 32bit.
|
Message |
version(int version)
For deserialization.
|
public static final int CONTENT_TYPE_LENGTH
public int messageId()
public Message messageId(int messageId)
messageId - The message Idpublic int version()
public Message version(int version)
version - The 24bit versionpublic Message.Type type()
public Message type(Message.Type type)
type - Type of the messagepublic byte command()
public Message command(byte command)
command - Commandpublic PeerAddress sender()
public Message sender(PeerAddress sender)
sender - The ID of the sender.public PeerAddress recipient()
public Message recipient(PeerAddress recipient)
recipient - The ID of the recipientpublic PeerAddress recipientRelay()
public Message recipientRelay(PeerAddress recipientRelay)
public Message.Content[] contentTypes()
public Message contentType(Message.Content contentType)
contentType - The content type to setpublic void restoreContentReferences()
public void restoreBuffers()
public Message contentType(int index, Message.Content contentType)
index - The indexcontentType - The content typepublic Message contentTypes(Message.Content[] contentTypes)
contentTypes - The content types that were decoded.public Queue<MessageContentIndex> contentReferences()
public boolean hasContent()
public Message hasContent(boolean content)
content - We can set this already in the header to know if we have content or notpublic boolean isRequest()
public boolean isFireAndForget()
public boolean isOk()
public boolean isNotOk()
public boolean isError()
public static boolean isError(Message.Type type)
type - The type to checkpublic Message options(int options)
options - The option from the last byte of the headerpublic int options()
public Message keepAlive(boolean isKeepAlive)
isKeepAlive - True if the connection should remain open. We need to announce this in the header, as otherwise the
other end has an idle handler that will close the connection.public boolean isKeepAlive()
public Message streaming()
public Message streaming(boolean streaming)
public boolean isStreaming()
public Number160 key(int index)
public Message bloomFilter(SimpleBloomFilter<Number160> bloomFilter)
public List<SimpleBloomFilter<Number160>> bloomFilterList()
public SimpleBloomFilter<Number160> bloomFilter(int index)
public Message intValue(int integer)
public Integer intAt(int index)
public Message longValue(long long0)
public Long longAt(int index)
public Message neighborsSet(NeighborSet neighborSet)
public List<NeighborSet> neighborsSetList()
public NeighborSet neighborsSet(int index)
public DataMap dataMap(int index)
public Message keyCollection(KeyCollection key)
public List<KeyCollection> keyCollectionList()
public KeyCollection keyCollection(int index)
public Message keyMap640Keys(KeyMap640Keys keyMap)
public List<KeyMap640Keys> keyMap640KeysList()
public KeyMap640Keys keyMap640Keys(int index)
public Message keyMapByte(KeyMapByte keyMap)
public List<KeyMapByte> keyMapByteList()
public KeyMapByte keyMapByte(int index)
public PublicKey publicKey(int index)
public Message peerSocketAddresses(Collection<PeerSocketAddress> peerSocketAddresses)
public List<PeerSocketAddress> peerSocketAddresses()
public PrivateKey privateKey()
public Buffer buffer(int index)
public Message trackerData(TrackerData trackerData)
public List<TrackerData> trackerDataList()
public TrackerData trackerData(int index)
public Message receivedSignature(SignatureCodec signatureEncode)
public SignatureCodec receivedSignature()
public Message presetContentTypes(boolean presetContentTypes)
presetContentTypes - True if the content type is already set.public Message senderSocket(InetSocketAddress senderSocket)
senderSocket - The sender as we saw it on the interfacepublic InetSocketAddress senderSocket()
public Message recipientSocket(InetSocketAddress recipientSocket)
recipientSocket - The recipient as we saw it on the interfacepublic InetSocketAddress recipientSocket()
public Message setHintSign()
public boolean isSign()
public Message udp(boolean udp)
udp - True if connection is UDPpublic boolean isUdp()
public Message verified(boolean verified)
public boolean verified()
public Message setVerified()
public Message setDone(boolean done)
done - True if message decoding or encoding is donepublic Message setDone()
public boolean isDone()
Copyright © 2014. All rights reserved.