Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
DatagramGeneratorNet Class Reference

This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection. More...

`#include "datagramGeneratorNet.h"`

Inheritance diagram for DatagramGeneratorNet:

## Public Member Functions
| DatagramGeneratorNet (ConnectionManager *manager, int num_threads)
| Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests.
virtual bool | get_datagram (Datagram &data)
| Reads the next datagram from the stream.
virtual bool | is_eof ()
| Returns true if the stream has been closed normally.
virtual bool | is_error ()
| Returns true if the stream has an error condition.
Public Member Functions inherited from DatagramGenerator
| DatagramGenerator ()
| Does nothing since this is class is just the definition of an interface.
virtual | ~DatagramGenerator ()
| Does nothing since this is class is just the definition of an interface.
virtual const FileReference * | get_file ()
| Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a file on disk.
virtual std::streampos | get_file_pos ()
| Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined.
virtual const Filename & | get_filename ()
| Returns the filename that provides the source for these datagrams, if any, or empty string if the datagrams do not originate from a file on disk.
virtual time_t | get_timestamp () const
| Returns the on-disk timestamp of the file that was read, at the time it was opened, if that is available, or 0 if it is not.
virtual VirtualFile * | get_vfile ()
| Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a VirtualFile.
virtual bool | save_datagram (SubfileInfo &info)
| Skips over the next datagram without extracting it, but saves the relevant file information in the SubfileInfo object so that its data may be read later.
Public Member Functions inherited from ConnectionReader
| ConnectionReader (ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
| Creates a new ConnectionReader with the indicated number of threads to handle requests.
bool | add_connection (Connection *connection)
| Adds a new socket to the list of sockets the ConnectionReader will monitor.
ConnectionManager * | get_manager () const
| Returns a pointer to the ConnectionManager object that serves this ConnectionReader.
int | get_num_threads () const
| Returns the number of threads the ConnectionReader has been created with.
bool | get_raw_mode () const
| Returns the current setting of the raw mode flag.
int | get_tcp_header_size () const
| Returns the current setting of TCP header size.
bool | is_connection_ok (Connection *connection)
| Returns true if the indicated connection has been added to the ConnectionReader and is being monitored properly, false if it is not known, or if there was some error condition detected on the connection.
bool | is_polling () const
| Returns true if the reader is a polling reader, i.e.
void | poll ()
| Explicitly polls the available sockets to see if any of them have any noise.
bool | remove_connection (Connection *connection)
| Removes a socket from the list of sockets being monitored.
void | set_raw_mode (bool mode)
| Sets the ConnectionReader into raw mode (or turns off raw mode).
void | set_tcp_header_size (int tcp_header_size)
| Sets the header size of TCP packets.
void | shutdown ()
| Terminates all threads cleanly.
Public Member Functions inherited from QueuedReturn< Datagram >
int | get_current_queue_size () const
| Returns the current number of things in the queue.
int | get_max_queue_size () const
| Returns the maximum size the queue is allowed to grow to.
bool | get_overflow_flag () const
| Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that some elements have been dropped from the queue), or false otherwise.
void | reset_overflow_flag ()
| Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs.
void | set_max_queue_size (int max_size)
| Sets the maximum size the queue is allowed to grow to.

## Detailed Description

This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection.

If a datagram is not available, get_datagram() will block until one is.

Definition at line 33 of file datagramGeneratorNet.h.

## Constructor & Destructor Documentation

## ◆ DatagramGeneratorNet()

DatagramGeneratorNet::DatagramGeneratorNet | ( | ConnectionManager * | manager,
|  | int | num_threads )
| explicit

Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests.

Normally num_threads should be either 0 or 1 to guarantee that datagrams are generated in the same order in which they were received.

Definition at line 27 of file datagramGeneratorNet.cxx.

References ConnectionReader::ConnectionReader().

## ◆ ~DatagramGeneratorNet()

DatagramGeneratorNet::~DatagramGeneratorNet | ( |  | ) |
| virtual

Definition at line 38 of file datagramGeneratorNet.cxx.

## Member Function Documentation

## ◆ get_datagram()

bool DatagramGeneratorNet::get_datagram | ( | Datagram & | data | ) |
| virtual

Reads the next datagram from the stream.

Blocks until a datagram is available. Returns true on success, false on stream closed or error.

Implements DatagramGenerator.

Definition at line 46 of file datagramGeneratorNet.cxx.

References Thread::force_yield(), is_eof(), ConnectionReader::is_polling(), and ConnectionReader::poll().

## ◆ is_eof()

bool DatagramGeneratorNet::is_eof | ( |  | ) |
| virtual

Returns true if the stream has been closed normally.

This test may only be made after a call to get_datagram() has failed.

Implements DatagramGenerator.

Definition at line 106 of file datagramGeneratorNet.cxx.

Referenced by get_datagram().

## ◆ is_error()

bool DatagramGeneratorNet::is_error | ( |  | ) |
| virtual

Returns true if the stream has an error condition.

Implements DatagramGenerator.

Definition at line 116 of file datagramGeneratorNet.cxx.

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

- panda/src/net/datagramGeneratorNet.h
- panda/src/net/datagramGeneratorNet.cxx