public class RawMessage extends Object
Modifier and Type | Field and Description |
---|---|
private TransportAddress |
localAddress
The address that this message was received on.
|
private byte[] |
messageBytes
The message itself.
|
private int |
messageLength
The length of the message.
|
private TransportAddress |
remoteAddress
The address and port where the message was sent from.
|
Constructor and Description |
---|
RawMessage(byte[] messageBytes,
int messageLength,
TransportAddress remoteAddress,
TransportAddress localAddress)
Constructs a raw message with the specified field values.
|
Modifier and Type | Method and Description |
---|---|
static RawMessage |
build(byte[] messageBytes,
int messageLength,
TransportAddress remoteAddress,
TransportAddress localAddress)
Use builder pattern to allow creation of immutable RawMessage instances,
from outside the current package.
|
byte[] |
getBytes()
Returns the message itself.
|
TransportAddress |
getLocalAddress()
Returns the address that this message was received on.
|
int |
getMessageLength()
Returns the message length.
|
TransportAddress |
getRemoteAddress()
Returns the address and port of the host that sent the message
|
private final byte[] messageBytes
private final int messageLength
private final TransportAddress remoteAddress
private final TransportAddress localAddress
RawMessage(byte[] messageBytes, int messageLength, TransportAddress remoteAddress, TransportAddress localAddress)
messageBytes
- the message itself.messageLength
- the number of bytes currently stored in the
messageBytes array.remoteAddress
- the address where the message came from.localAddress
- the TransportAddress that the message was
received on.NullPointerException
- if one or more of the parameters were null.public byte[] getBytes()
public int getMessageLength()
public TransportAddress getRemoteAddress()
public TransportAddress getLocalAddress()
public static RawMessage build(byte[] messageBytes, int messageLength, TransportAddress remoteAddress, TransportAddress localAddress)
messageBytes
- the message itself.messageLength
- the number of bytes currently stored in the
messageBytes array.remoteAddress
- the address where the message came from.localAddress
- the TransportAddress that the message was
received on.Copyright © 2018. All rights reserved.