YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.fcast.protocol.FCastFrameReader Class Reference

Reads the packets of FCast protocol v3 from a stream (see FCastPacketCodec). More...

Collaboration diagram for de.yaacc.fcast.protocol.FCastFrameReader:
Collaboration graph

Public Member Functions

 FCastFrameReader (InputStream in)
 The reader of versions 1 to 3: packets of at most FCastPacketCodec#MAX_PACKET bytes, every body is text.
 
 FCastFrameReader (InputStream in, int maxPacket, boolean binaryFlatbuf)
 
FCastPacket read () throws IOException
 

Detailed Description

Reads the packets of FCast protocol v3 from a stream (see FCastPacketCodec).

The stream may deliver any number of bytes per read; a packet is assembled from as many reads as it takes. Not thread safe: one reader thread.

Rules (the receivers end the connection on the same): a size of 0 (EMPTY_PACKET), a size over FCastPacketCodec#MAX_PACKET (OVERSIZE; nothing of the body is read, no memory is allocated for it) and a stream that ends inside a packet (TRUNCATED) are errors that end the connection; a stream that ends between two packets is the normal end. A body that is not valid UTF-8 is BAD_BODY, which does not end the connection (the packet was read completely). An unknown opcode is returned like any other: the caller skips it.

Constructor & Destructor Documentation

◆ FCastFrameReader()

de.yaacc.fcast.protocol.FCastFrameReader.FCastFrameReader ( InputStream in,
int maxPacket,
boolean binaryFlatbuf )
Parameters
maxPacketthe most bytes after the size field (FCastPacketCodec#MAX_PACKET_V4 for version 4)
binaryFlatbuftrue for version 4: the bodies of the Flatbuf and Resource opcodes are bytes, not text

Member Function Documentation

◆ read()

FCastPacket de.yaacc.fcast.protocol.FCastFrameReader.read ( ) throws IOException
Returns
the next packet, or null if the stream ended before the first byte of a packet
Exceptions
FCastProtocolExceptionfor the cases above
IOExceptionif the stream fails (including a timeout set on a socket)

The documentation for this class was generated from the following file: