Class UniteMessage

java.lang.Object
org.drasyl.handler.remote.protocol.UniteMessage
All Implemented Interfaces:
FullReadMessage<UniteMessage>, RemoteMessage

public abstract class UniteMessage extends Object
  • Field Details

  • Constructor Details

    • UniteMessage

      public UniteMessage()
  • Method Details

    • getAddress

      public abstract DrasylAddress getAddress()
      Returns the public key of the peer.
      Returns:
      the public key of the peer.
    • getInetAddress

      public abstract InetAddress getInetAddress()
      Returns the ip address of the peer.
      Returns:
      the ip address of the peer.
    • getPort

      public abstract UnsignedShort getPort()
      Returns the port of the peer.
      Returns:
      the port of the peer.
    • getSocketAddress

      public InetSocketAddress getSocketAddress()
    • incrementHopCount

      public UniteMessage 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 UniteMessage of(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, DrasylAddress address, InetAddress inetAddress, UnsignedShort port)
      Creates new unit 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
      address - the public key of the peer
      inetAddress - the ip address of the peer
      port - the port of the peer
      Throws:
      NullPointerException - if nonce, sender, proofOfWork, recipient, hopCount, address, or inetAddress is null
      IllegalArgumentException - if port is invalid
    • of

      public static UniteMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, InetSocketAddress inetAddress)
      Creates new unit message with random Nonce, and minimal HopCount value.
      Parameters:
      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
      address - the public key of the peer
      inetAddress - the ip inetAddress and port of the peer
      Throws:
      NullPointerException - if sender, proofOfWork, recipient, address, or inetAddress.getAddress() is null
      IllegalArgumentException - if inetAddress.getPort() is invalid
    • 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 interface FullReadMessage<T extends FullReadMessage<?>>
      Parameters:
      byteBuf - the ByteBuf to write through
      cryptoInstance - the crypto instance that should be used
      sessionPair - 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 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)