Class UniteMessage
java.lang.Object
org.drasyl.handler.remote.protocol.UniteMessage
- All Implemented Interfaces:
FullReadMessage<UniteMessage>,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 DrasylAddressReturns the public key of the peer.abstract InetAddressReturns the ip address of the peer.abstract UnsignedShortgetPort()Returns the port of the peer.Returns this message with incremented hop count.static UniteMessageof(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, InetSocketAddress inetAddress) static UniteMessageof(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, DrasylAddress address, InetAddress inetAddress, UnsignedShort port) Creates new unit 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.FullReadMessage
getRecipientMethods 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
-
UniteMessage
public UniteMessage()
-
-
Method Details
-
getAddress
Returns the public key of the peer.- Returns:
- the public key of the peer.
-
getInetAddress
Returns the ip address of the peer.- Returns:
- the ip address of the peer.
-
getPort
Returns the port of the peer.- Returns:
- the port of the peer.
-
getSocketAddress
-
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 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 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 ofsenderaddress- the public key of the peerinetAddress- the ip address of the peerport- the port of the peer- Throws:
NullPointerException- ifnonce,sender,proofOfWork,recipient,hopCount,address, orinetAddressisnullIllegalArgumentException- ifportis invalid
-
of
public static UniteMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, InetSocketAddress inetAddress) - Parameters:
networkId- the network idrecipient- the public key of the recipientsender- the public key of the senderproofOfWork- the proof of work ofsenderaddress- the public key of the peerinetAddress- the ip inetAddress and port of the peer- Throws:
NullPointerException- ifsender,proofOfWork,recipient,address, orinetAddress.getAddress()isnullIllegalArgumentException- ifinetAddress.getPort()is invalid
-
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)
-