Class HelloMessage

  • All Implemented Interfaces:
    FullReadMessage<HelloMessage>, RemoteMessage

    public abstract class HelloMessage
    extends Object
    Describes a message that is used to announce this node to peers or to join a super node. The message's body is structured as follows:
    • Time: The sender's current time in milliseconds stored in 8 bytes.
    • ChildrenTime: Specifies how many seconds (8 bytes) the sender wants to join the receiving super peer. If the value is 0, the message is an announcement and not a join.
    • Signature: 64 byte signature. Only present if ChildrenTime is > 0.

    This is an immutable object.

    • Constructor Detail

      • HelloMessage

        public HelloMessage()
    • Method Detail

      • of

        public static HelloMessage of​(HopCount hopCount,
                                      boolean isArmed,
                                      int networkId,
                                      Nonce nonce,
                                      DrasylAddress recipient,
                                      DrasylAddress sender,
                                      ProofOfWork proofOfWork,
                                      long time,
                                      long childrenTime,
                                      ImmutableByteArray signature)
        Creates new application message.
        Parameters:
        hopCount - the hop count
        isArmed - if the message is armed or not
        networkId - the network id
        nonce - the nonce
        recipient - the public key of the recipient
        sender - the public key of the sender
        proofOfWork - the proof of work of sender
        time -
        childrenTime - the join time
        signature -
        Throws:
        NullPointerException - if nonce, sender, proofOfWork, recipient, or hopCount is null
      • of

        public static HelloMessage of​(HopCount hopCount,
                                      boolean isArmed,
                                      int networkId,
                                      Nonce nonce,
                                      DrasylAddress recipient,
                                      DrasylAddress sender,
                                      ProofOfWork proofOfWork,
                                      long time,
                                      long childrenTime,
                                      IdentitySecretKey secretKey)
        Creates new application message.
        Parameters:
        hopCount - the hop count
        isArmed - if the message is armed or not
        networkId - the network id
        nonce - the nonce
        recipient - the public key of the recipient
        sender - the public key of the sender
        proofOfWork - the proof of work of sender
        time -
        childrenTime - the join time
        signature -
        Throws:
        NullPointerException - if nonce, sender, proofOfWork, recipient, or hopCount is null
      • of

        public static HelloMessage of​(int networkId,
                                      DrasylAddress recipient,
                                      IdentityPublicKey sender,
                                      ProofOfWork proofOfWork,
                                      long time,
                                      long childrenTime,
                                      IdentitySecretKey secretKey)
        Creates a new HelloMessage message.
        Parameters:
        networkId - the network of the joining node
        recipient - the public key of the node to join
        sender - the public key of the joining node
        proofOfWork - the proof of work
        time - time in millis when this message was sent
        childrenTime - if 0 greater then 0, node will join a children.
        secretKey - the secret key used to sign this message
        Throws:
        NullPointerException - if sender, proofOfWork, or recipient is null
      • of

        public static HelloMessage of​(int networkId,
                                      DrasylAddress recipient,
                                      IdentityPublicKey sender,
                                      ProofOfWork proofOfWork,
                                      long childrenTime,
                                      IdentitySecretKey secretKey)
        Creates a new HelloMessage message.
        Parameters:
        networkId - the network of the joining node
        recipient - the public key of the node to join
        sender - the public key of the joining node
        proofOfWork - the proof of work
        childrenTime - if 0 greater then 0, node will join a children.
        secretKey - the secret key used to sign this message
        Throws:
        NullPointerException - if sender, proofOfWork, or recipient is null
      • of

        public static HelloMessage of​(int networkId,
                                      DrasylAddress recipient,
                                      IdentityPublicKey sender,
                                      ProofOfWork proofOfWork)
        Creates a new HelloMessage message.
        Parameters:
        networkId - the network of the joining node
        recipient - the public key of the node to join
        sender - the public key of the joining node
        proofOfWork - the proof of work
        Throws:
        NullPointerException - if sender, proofOfWork, or recipient is null
      • getRecipient

        @Nullable
        public abstract DrasylAddress getRecipient()
        Returns the IdentityPublicKey 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 than 0, 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

        public HelloMessage incrementHopCount()
        Description copied from interface: FullReadMessage
        Returns this message with incremented hop count.
        Returns:
        this message with incremented hop count.
      • isSigned

        public boolean isSigned()
        Returns true if message is signed. This message will not verifiy the signature! Use verifySignature() to check if supplied signature is valid.
        Returns:
        true if message is signed
      • verifySignature

        public boolean verifySignature()
        Returns true if message is signed and the signature is valid. Use isSigned() to check whether a message is signed.
        Returns:
        true if message is signed and the signature is valid
      • writePrivateHeaderTo

        protected void writePrivateHeaderTo​(io.netty.buffer.ByteBuf out)
      • writeBodyTo

        protected void writeBodyTo​(io.netty.buffer.ByteBuf out)
      • writeTo

        public void writeTo​(io.netty.buffer.ByteBuf out)
        Description copied from interface: RemoteMessage
        Writes this message to the buffer out.
        Specified by:
        writeTo in interface RemoteMessage
        Parameters:
        out - writes this envelope to this buffer
      • writePublicHeaderTo

        protected void writePublicHeaderTo​(io.netty.buffer.ByteBuf out)