Interface PartialReadMessage
- All Superinterfaces:
AutoCloseable,io.netty.util.ReferenceCounted,RemoteMessage
- All Known Implementing Classes:
ArmedProtocolMessage,UnarmedProtocolMessage
@UnstableApi
public interface PartialReadMessage
extends RemoteMessage, io.netty.util.ReferenceCounted, AutoCloseable
Describes a message whose content has been read partially. This is the case for encrypted
messages, chunks or messages that do not need to be read completely.
- See Also:
-
Field Summary
Fields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER, MAGIC_NUMBER_LEN -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()CallsReferenceCounted.release().io.netty.buffer.ByteBufgetBytes()Returns the remainder of unread bytes of this message.static PartialReadMessageof(io.netty.buffer.ByteBuf bytes) Creates aPartialReadMessagefrombytes.static PartialReadMessageof(PublicHeader publicHeader, io.netty.buffer.ByteBuf bytes) Methods inherited from interface io.netty.util.ReferenceCounted
refCnt, release, release, retain, retain, touch, touchMethods inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
getArmed, getHopCount, getLength, getNetworkId, getNonce, getProofOfWork, getRecipient, getSender, incrementHopCount, writeTo
-
Method Details
-
getBytes
io.netty.buffer.ByteBuf getBytes()Returns the remainder of unread bytes of this message.- Returns:
- the remainder of unread bytes of this message
-
close
void close()CallsReferenceCounted.release().- Specified by:
closein interfaceAutoCloseable
-
of
Creates aPartialReadMessagefrompublicHeaderandbytes.- In case
publicHeader.getArmed()istrue,ArmedProtocolMessageobject is returned. - In all other cases,
UnarmedProtocolMessageobject is returned.
ReferenceCounted.release()ownership ofbytesis transferred to thisPartialReadMessage.Modifying the content of
bytesor the returned message's buffer affects each other's content while they maintain separate indexes and marks.- Parameters:
publicHeader- message's public headerbytes- message's remainder as bytes (may be armed).ReferenceCounted.release()ownership is transferred to thisPartialReadMessage.- Returns:
- an
PartialReadMessageobject - Throws:
NullPointerException- ifpublicHeader.getNonce(),publicHeader.getSender(),publicHeader.getProofOfWork(), orpublicHeader.getRecipient()isnullIllegalArgumentException- ifpublicHeader.getSender()orpublicHeader.getRecipient()has wrong key size, orpublicHeader.getAgreementId()is neithernullnor a valid SHA256 hash
- In case
-
of
Creates aPartialReadMessagefrombytes. First, this method checks ifbytesstarts withRemoteMessage.MAGIC_NUMBER, then reads the message's public header:- In case
publicHeader.getArmed()istrue,ArmedProtocolMessageobject is returned. - In all other cases,
UnarmedProtocolMessageobject is returned.
ReferenceCounted.release()ownership ofbytesis transferred to thisPartialReadMessage.Modifying the content of
bytesor the returned message's buffer affects each other's content while they maintain separate indexes and marks.- Parameters:
bytes- message's bytes (may be partially armed).ReferenceCounted.release()ownership is transferred to thisPartialReadMessage.- Returns:
- an
PartialReadMessageobject - Throws:
NullPointerException- ifpublicHeader.getNonce(),publicHeader.getSender(),publicHeader.getProofOfWork(), orpublicHeader.getRecipient()isnullIllegalArgumentException- ifpublicHeader.getSender()orpublicHeader.getRecipient()has wrong key size, orpublicHeader.getAgreementId()is neithernullnor a valid SHA256 hashInvalidMessageFormatException- if magic number or public header is missing
- In case
-