Interface PartialReadMessage
- All Superinterfaces:
- AutoCloseable,- io.netty.util.ReferenceCounted,- RemoteMessage
- All Known Implementing Classes:
- ArmedProtocolMessage,- UnarmedProtocolMessage
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 SummaryFields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessageMAGIC_NUMBER
- 
Method SummaryModifier 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.ReferenceCountedrefCnt, release, release, retain, retain, touch, touchMethods inherited from interface org.drasyl.handler.remote.protocol.RemoteMessagegetArmed, getHopCount, getNetworkId, getNonce, getProofOfWork, getRecipient, getSender, incrementHopCount, writeTo
- 
Method Details- 
getBytesio.netty.buffer.ByteBuf getBytes()Returns the remainder of unread bytes of this message.- Returns:
- the remainder of unread bytes of this message
 
- 
closevoid close()CallsReferenceCounted.release().- Specified by:
- closein interface- AutoCloseable
 
- 
ofCreates 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 header
- bytes- message's remainder as bytes (may be armed).- ReferenceCounted.release()ownership is transferred to this- PartialReadMessage.
- Returns:
- an PartialReadMessageobject
- Throws:
- NullPointerException- if- publicHeader.getNonce(),- publicHeader.getSender(),- publicHeader.getProofOfWork(), or- publicHeader.getRecipient()is- null
- IllegalArgumentException- if- publicHeader.getSender()or- publicHeader.getRecipient()has wrong key size, or- publicHeader.getAgreementId()is neither- nullnor a valid SHA256 hash
 
- In case 
- 
ofCreates 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 this- PartialReadMessage.
- Returns:
- an PartialReadMessageobject
- Throws:
- NullPointerException- if- publicHeader.getNonce(),- publicHeader.getSender(),- publicHeader.getProofOfWork(), or- publicHeader.getRecipient()is- null
- IllegalArgumentException- if- publicHeader.getSender()or- publicHeader.getRecipient()has wrong key size, or- publicHeader.getAgreementId()is neither- nullnor a valid SHA256 hash
- InvalidMessageFormatException- if magic number or public header is missing
 
- In case 
 
-