Panda3D
buffered_datagramreader.I
1 
2 /**
3  * A function that will peal a core message of the input buffer
4  */
5 inline bool Buffered_DatagramReader::
6 GetMessageFromBuffer(Datagram &inmsg) {
7  bool answer = false;
8  size_t DataAvail = FastAmountBeffered();
9  if (DataAvail >= sizeof(short)) {
10  char *ff = FastGetMessageHead();
11  unsigned short len=GetUnsignedShort(ff);
12  len += sizeof(unsigned short);
13  if (len <= DataAvail) {
14  inmsg.assign(ff + 2, len - 2);
15  _StartPos += len;
16  answer = true;
17  }
18  }
19  return answer;
20 }
21 /**
22  * Constructor. Passes size up to ring buffer.
23  */
25 Buffered_DatagramReader(int in_size) : RingBuffer(in_size) {
26 }
27 
28 /**
29  * Reset all read content, ie. zeroes out buffer.
30  *
31  * If you lose framing, this will not help.
32  */
33 inline void Buffered_DatagramReader::
34 ReSet(void) {
35  ResetContent();
36 }
void ReSet(void)
Reset all read content, ie.
void assign(const void *data, size_t size)
Replaces the datagram's data with the indicated block.
Definition: datagram.cxx:159
void ResetContent(void)
Throw away all inread information.
Definition: ringbuffer.I:51
Buffered_DatagramReader(int in_size=8192)
Constructor.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38