Class DiscoveryMessage
java.lang.Object
org.drasyl.handler.remote.protocol.DiscoveryMessage
- All Implemented Interfaces:
FullReadMessage<DiscoveryMessage>
,RemoteMessage
-
Field Summary
Fields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER
-
Constructor Summary
-
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 long
If the value is greater than0
, it indicates that this node wants to join the receiver as a child.abstract DrasylAddress
Returns theIdentityPublicKey
of the message recipient.abstract long
getTime()
Returns the time this message has been sent.Returns this message with incremented hop count.static DiscoveryMessage
of
(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long childrenTime) Creates a newDiscoveryMessage
message.static DiscoveryMessage
of
(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time, long childrenTime) Creates a newDiscoveryMessage
message.static DiscoveryMessage
of
(int networkId, IdentityPublicKey sender, ProofOfWork proofOfWork) Creates a new multicastDiscoveryMessage
message (sent byLocalNetworkDiscovery
}.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.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.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 theIdentityPublicKey
of the message recipient. If the message has no recipient (e.g. because it is a multicast message)null
is 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: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) -
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 ofsender
time
-joinTime
- the join time- Throws:
NullPointerException
- ifnonce
,sender
,proofOfWork
,recipient
, orhopCount
isnull
-
of
public static DiscoveryMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long time, long childrenTime) Creates a newDiscoveryMessage
message.- 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
- if0
greater then 0, node will join a children.- Throws:
NullPointerException
- ifsender
,proofOfWork
, orrecipient
isnull
-
of
public static DiscoveryMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, long childrenTime) Creates a newDiscoveryMessage
message.- 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
- if0
greater then 0, node will join a children.- Throws:
NullPointerException
- ifsender
,proofOfWork
, orrecipient
isnull
-
of
Creates a new multicastDiscoveryMessage
message (sent byLocalNetworkDiscovery
}.- Parameters:
networkId
- the network of the joining nodesender
- the public key of the joining nodeproofOfWork
- the proof of work- Throws:
NullPointerException
- ifsender
, orproofOfWork
isnull
-
arm
public ArmedProtocolMessage arm(io.netty.buffer.ByteBuf byteBuf, 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<?>>
- Parameters:
byteBuf
- theByteBuf
to 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: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)
-