Class AcknowledgementMessage
java.lang.Object
org.drasyl.handler.remote.protocol.AcknowledgementMessage
- All Implemented Interfaces:
FullReadMessage<AcknowledgementMessage>
,RemoteMessage
Acknowledges a
HelloMessage
. The message's body is structured as follows:
- Time: The received
HelloMessage.getTime()
value this message is refers (8 bytes).
This is an immutable object.
-
Field Summary
Fields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER, MAGIC_NUMBER_LEN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionarm
(io.netty.buffer.ByteBufAllocator alloc, Crypto cryptoInstance, SessionPair sessionPair) Returns an armed version (ArmedProtocolMessage
) of this message for sending it through untrustworthy channels.int
abstract long
getTime()
Returns theHelloMessage.getTime()
value of the correspondingHelloMessage
.Returns this message with incremented hop count.static AcknowledgementMessage
of
(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time) static AcknowledgementMessage
of
(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, long time) Creates new acknowledgement message.protected void
writeBodyTo
(io.netty.buffer.ByteBuf out) protected void
writePrivateHeaderTo
(io.netty.buffer.ByteBuf out) protected void
writePublicHeaderTo
(io.netty.buffer.ByteBuf out) void
writeTo
(io.netty.buffer.ByteBuf out) Writes this message to the bufferout
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.drasyl.handler.remote.protocol.FullReadMessage
getRecipient
Methods inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
getArmed, getHopCount, getNetworkId, getNonce, getProofOfWork, getSender
-
Field Details
-
LENGTH
public static final int LENGTH- See Also:
-
-
Constructor Details
-
AcknowledgementMessage
public AcknowledgementMessage()
-
-
Method Details
-
of
public static AcknowledgementMessage of(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, long time) Creates new acknowledgement message.- Parameters:
hopCount
- the hop countisArmed
-networkId
- the network idnonce
- the noncerecipient
- the public key of the recipientsender
- the public key of the senderproofOfWork
- the proof of work ofsender
- Throws:
NullPointerException
- ifnonce
,sender
,proofOfWork
,recipient
,hopCount
, orcorrespondingId
isnull
-
of
public static AcknowledgementMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time) - Parameters:
networkId
- the network idrecipient
- the public key of the recipientsender
- the public key of the senderproofOfWork
- the proof of work ofsender
- Throws:
NullPointerException
- ifsender
,proofOfWork
,recipient
, orcorrespondingId
isnull
-
getTime
public abstract long getTime()Returns theHelloMessage.getTime()
value of the correspondingHelloMessage
. -
incrementHopCount
Description copied from interface:FullReadMessage
Returns this message with incremented hop count.- Returns:
- this message with incremented hop count.
-
writePrivateHeaderTo
protected void writePrivateHeaderTo(io.netty.buffer.ByteBuf out) -
writeBodyTo
protected void writeBodyTo(io.netty.buffer.ByteBuf out) -
getLength
public int getLength() -
arm
public ArmedProtocolMessage arm(io.netty.buffer.ByteBufAllocator alloc, Crypto cryptoInstance, SessionPair sessionPair) throws InvalidMessageFormatException Description copied from interface:FullReadMessage
Returns an armed version (ArmedProtocolMessage
) of this message for sending it through untrustworthy channels.- Specified by:
arm
in interfaceFullReadMessage<T extends FullReadMessage<?>>
cryptoInstance
- the crypto instance that should be usedsessionPair
- will be used for encryption- Returns:
- the armed version of this message
- Throws:
InvalidMessageFormatException
- if arming was not possible
-
writeTo
public void writeTo(io.netty.buffer.ByteBuf out) Description copied from interface:RemoteMessage
Writes this message to the bufferout
.- Specified by:
writeTo
in interfaceRemoteMessage
- Parameters:
out
- writes this envelope to this buffer
-
writePublicHeaderTo
protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)
-