Class ArmedProtocolMessage

    • Constructor Detail

      • ArmedProtocolMessage

        public ArmedProtocolMessage()
    • Method Detail

      • refCnt

        public int refCnt()
        Specified by:
        refCnt in interface io.netty.util.ReferenceCounted
      • retain

        public io.netty.util.ReferenceCounted retain()
        Specified by:
        retain in interface io.netty.util.ReferenceCounted
      • retain

        public io.netty.util.ReferenceCounted retain​(int increment)
        Specified by:
        retain in interface io.netty.util.ReferenceCounted
      • touch

        public io.netty.util.ReferenceCounted touch()
        Specified by:
        touch in interface io.netty.util.ReferenceCounted
      • touch

        public io.netty.util.ReferenceCounted touch​(Object hint)
        Specified by:
        touch in interface io.netty.util.ReferenceCounted
      • release

        public boolean release()
        Specified by:
        release in interface io.netty.util.ReferenceCounted
      • release

        public boolean release​(int decrement)
        Specified by:
        release in interface io.netty.util.ReferenceCounted
      • disarmAndRelease

        public FullReadMessage<?> disarmAndRelease​(Crypto cryptoInstance,
                                                   SessionPair sessionPair)
                                            throws InvalidMessageFormatException
        Returns a disarmed version (FullReadMessage) of this message and then releases this message.

        Disarming will authenticate the nonce, network id, sender, sender's proof of work, recipient, agreement id, and decrypt all remaining bytes.

        Parameters:
        cryptoInstance - the crypto instance that should be used
        sessionPair - the SessionPair to decrypt this message
        Returns:
        the disarmed version of this message
        Throws:
        InvalidMessageFormatException - if disarming was not possible
      • 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
      • of

        public static ArmedProtocolMessage of​(Nonce nonce,
                                              HopCount hopCount,
                                              int networkId,
                                              DrasylAddress recipient,
                                              DrasylAddress sender,
                                              ProofOfWork proofOfWork,
                                              io.netty.buffer.ByteBuf bytes)
        Creates an armed message.

        ReferenceCounted.release() ownership of bytes is transferred to this PartialReadMessage.

        Modifying the content of bytes or the returned message's buffer affects each other's content while they maintain separate indexes and marks.

        Parameters:
        nonce - the nonce
        hopCount - the hop count
        networkId - the network id
        recipient - the public key of the recipient
        sender - the public key of the sender
        proofOfWork - the proof of work of sender
        bytes - the message's remaining armed bytes
        Throws:
        NullPointerException - if nonce, sender, proofOfWork, recipient, hopCount, agreementId, or bytes is null