Support Forum       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::NetServer Class Reference


Manages connections for a machine that accepts incoming ones. More...

Inherits G3D::ReferenceCountedObject.

Public Types

enum  {
  UNLIMITED_BANDWIDTH = 0,
  MAX_CHANNELS = 255
}
 

Public Member Functions

 ~NetServer ()
 Drop all connections and stop listening for new ones. More...
 
NetConnectionIteratornewConnectionIterator ()
 Causes the system to check for new incoming connections and then returns an iterator over them. More...
 
const shared_ptr< NetSendConnection > & omniConnection () const
 A connection that sends to all connected clients (not a UDP broadcast to the subnet) More...
 
void stop ()
 Stop listenening for connections and shut down all clients. More...
 

Static Public Member Functions

static shared_ptr< NetServercreate (const NetAddress &myAddress, int maxClients=32, uint32 numChannels=1, size_t incomingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH, size_t outgoingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH)
 
static shared_ptr< NetServercreate (uint16 listenPort, int maxClients=32, uint32 numChannels=1, size_t incomingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH, size_t outgoingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH)
 

Protected Types

typedef Table< _ENetPeer *, shared_ptr< _internal::NetServerSideConnection > > ClientTable
 

Protected Member Functions

 NetServer (_ENetHost *host)
 
void serviceHost ()
 Service the ENetHost, checking for incoming messages and connections and depositing them in the appropriate queues. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Protected Attributes

ClientTable m_client
 
_ENetHost * m_enetHost
 
NetConnectionIterator m_newConnectionIterator
 Contains the queue. More...
 
shared_ptr< NetSendConnectionm_omniConnection
 

Friends

class _internal::NetServerSideConnection
 
class NetConnectionIterator
 
void serviceNetwork ()
 If NOT using G3D's internal threaded networking, you must invoke this periodically to service the receiving side network connections. More...
 

Detailed Description


Manages connections for a machine that accepts incoming ones.

This is similar to a TCP listener socket, but also supports efficient sending to all connected clients.

If you drop all pointers to a NetServer, then its NetConnections will be DISCONNECTED but they will still exist and already-received pending messages can be read from them.

You must invoke some method on NetServer or on a NetConnection created from it every frame to service the network on the main thread.

Member Typedef Documentation

◆ ClientTable

typedef Table<_ENetPeer*, shared_ptr<_internal::NetServerSideConnection> > G3D::NetServer::ClientTable
protected

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
See also
connectToServer
Enumerator
UNLIMITED_BANDWIDTH 
MAX_CHANNELS 

Constructor & Destructor Documentation

◆ NetServer()

G3D::NetServer::NetServer ( _ENetHost *  host)
protected

◆ ~NetServer()

G3D::NetServer::~NetServer ( )

Drop all connections and stop listening for new ones.

Member Function Documentation

◆ create() [1/2]

static shared_ptr<NetServer> G3D::NetServer::create ( const NetAddress myAddress,
int  maxClients = 32,
uint32  numChannels = 1,
size_t  incomingBytesPerSecondThrottle = UNLIMITED_BANDWIDTH,
size_t  outgoingBytesPerSecondThrottle = UNLIMITED_BANDWIDTH 
)
static
Parameters
myAddressSelects which local adapter and port to listen for incoming connections on
See also
NetConnection::connectToServer

Referenced by create().

◆ create() [2/2]

static shared_ptr<NetServer> G3D::NetServer::create ( uint16  listenPort,
int  maxClients = 32,
uint32  numChannels = 1,
size_t  incomingBytesPerSecondThrottle = UNLIMITED_BANDWIDTH,
size_t  outgoingBytesPerSecondThrottle = UNLIMITED_BANDWIDTH 
)
inlinestatic

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ newConnectionIterator()

NetConnectionIterator& G3D::NetServer::newConnectionIterator ( )
inline

Causes the system to check for new incoming connections and then returns an iterator over them.

◆ omniConnection()

const shared_ptr<NetSendConnection>& G3D::NetServer::omniConnection ( ) const
inline

A connection that sends to all connected clients (not a UDP broadcast to the subnet)

◆ serviceHost()

void G3D::NetServer::serviceHost ( )
protected

Service the ENetHost, checking for incoming messages and connections and depositing them in the appropriate queues.

Invoked by NetServerSideConnection::serviceHost(), incomingConnectionIterator(), and incomingConnectionIterator().

◆ stop()

void G3D::NetServer::stop ( )

Stop listenening for connections and shut down all clients.

Friends And Related Function Documentation

◆ _internal::NetServerSideConnection

friend class _internal::NetServerSideConnection
friend

◆ NetConnectionIterator

friend class NetConnectionIterator
friend

◆ serviceNetwork

void serviceNetwork ( )
friend

If NOT using G3D's internal threaded networking, you must invoke this periodically to service the receiving side network connections.

Receiving messages will only update inside this call–all other network calls queue for processing.

If using G3D's internal threaded networking, this is automatically called continuously on a separate thread.

See also
setNetworkCommunicationInterval, G3D::G3DSpecification::threadedNetwork

Member Data Documentation

◆ m_client

ClientTable G3D::NetServer::m_client
protected

◆ m_enetHost

_ENetHost* G3D::NetServer::m_enetHost
protected

◆ m_newConnectionIterator

NetConnectionIterator G3D::NetServer::m_newConnectionIterator
protected

Contains the queue.

Referenced by newConnectionIterator().

◆ m_omniConnection

shared_ptr<NetSendConnection> G3D::NetServer::m_omniConnection
protected

Referenced by omniConnection().


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15