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
FieldsFields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarm(io.netty.buffer.ByteBuf byteBuf, Crypto cryptoInstance, SessionPair sessionPair) Returns an armed version (ArmedProtocolMessage) of this message for sending it through untrustworthy channels.abstract longgetTime()Returns theHelloMessage.getTime()value of the correspondingHelloMessage.Returns this message with incremented hop count.static AcknowledgementMessageof(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time) static AcknowledgementMessageof(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, long time) Creates new acknowledgement message.protected voidwriteBodyTo(io.netty.buffer.ByteBuf out) protected voidwritePrivateHeaderTo(io.netty.buffer.ByteBuf out) protected voidwritePublicHeaderTo(io.netty.buffer.ByteBuf out) voidwriteTo(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, waitMethods inherited from interface org.drasyl.handler.remote.protocol.FullReadMessage
getRecipientMethods 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, orcorrespondingIdisnull
-
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, orcorrespondingIdisnull
-
getTime
public abstract long getTime()Returns theHelloMessage.getTime()value of the correspondingHelloMessage. -
incrementHopCount
Description copied from interface:FullReadMessageReturns 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) -
arm
public ArmedProtocolMessage arm(io.netty.buffer.ByteBuf byteBuf, Crypto cryptoInstance, SessionPair sessionPair) throws InvalidMessageFormatException Description copied from interface:FullReadMessageReturns an armed version (ArmedProtocolMessage) of this message for sending it through untrustworthy channels.- Specified by:
armin interfaceFullReadMessage<T extends FullReadMessage<?>>- Parameters:
byteBuf- theByteBufto write throughcryptoInstance- 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:RemoteMessageWrites this message to the bufferout.- Specified by:
writeToin interfaceRemoteMessage- Parameters:
out- writes this envelope to this buffer
-
writePublicHeaderTo
protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)
-