Class DiscoveryMessage
java.lang.Object
org.drasyl.handler.remote.protocol.DiscoveryMessage
- All Implemented Interfaces:
FullReadMessage<DiscoveryMessage>,RemoteMessage
-
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 longIf the value is greater than0, it indicates that this node wants to join the receiver as a child.abstract DrasylAddressReturns theIdentityPublicKeyof the message recipient.abstract longgetTime()Returns the time this message has been sent.Returns this message with incremented hop count.static DiscoveryMessageof(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long childrenTime) Creates a newDiscoveryMessagemessage.static DiscoveryMessageof(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time, long childrenTime) Creates a newDiscoveryMessagemessage.static DiscoveryMessageof(int networkId, IdentityPublicKey sender, ProofOfWork proofOfWork) Creates a new multicastDiscoveryMessagemessage (sent byLocalNetworkDiscovery}.static DiscoveryMessageof(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, long time, long joinTime) Creates new application 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.RemoteMessage
getArmed, getHopCount, getNetworkId, getNonce, getProofOfWork, getSender
-
Field Details
-
LENGTH
public static final int LENGTH- See Also:
-
-
Constructor Details
-
DiscoveryMessage
public DiscoveryMessage()
-
-
Method Details
-
getRecipient
Returns theIdentityPublicKeyof the message recipient. If the message has no recipient (e.g. because it is a multicast message)nullis returned.- Returns:
-
getTime
public abstract long getTime()Returns the time this message has been sent. -
getChildrenTime
public abstract long getChildrenTime()If the value is greater than0, it indicates that this node wants to join the receiver as a child. For this, the receiver must be configured as a super node. In all other cases, the message is used to announce this node's presence to the recipient. -
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) -
of
public static DiscoveryMessage of(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, long time, long joinTime) Creates new application message.- Parameters:
hopCount- the hop countisArmed- if the message is armed or notnetworkId- the network idnonce- the noncerecipient- the public key of the recipientsender- the public key of the senderproofOfWork- the proof of work ofsendertime-joinTime- the join time- Throws:
NullPointerException- ifnonce,sender,proofOfWork,recipient, orhopCountisnull
-
of
public static DiscoveryMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time, long childrenTime) Creates a newDiscoveryMessagemessage.- Parameters:
networkId- the network of the joining noderecipient- the public key of the node to joinsender- the public key of the joining nodeproofOfWork- the proof of worktime- time in millis when this message was sentchildrenTime- if0greater then 0, node will join a children.- Throws:
NullPointerException- ifsender,proofOfWork, orrecipientisnull
-
of
public static DiscoveryMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long childrenTime) Creates a newDiscoveryMessagemessage.- Parameters:
networkId- the network of the joining noderecipient- the public key of the node to joinsender- the public key of the joining nodeproofOfWork- the proof of workchildrenTime- if0greater then 0, node will join a children.- Throws:
NullPointerException- ifsender,proofOfWork, orrecipientisnull
-
of
Creates a new multicastDiscoveryMessagemessage (sent byLocalNetworkDiscovery}.- Parameters:
networkId- the network of the joining nodesender- the public key of the joining nodeproofOfWork- the proof of work- Throws:
NullPointerException- ifsender, orproofOfWorkisnull
-
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)
-