Support Forum G3D Web Page |
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... | |
NetConnectionIterator & | newConnectionIterator () |
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< NetServer > | create (const NetAddress &myAddress, int maxClients=32, uint32 numChannels=1, size_t incomingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH, size_t outgoingBytesPerSecondThrottle=UNLIMITED_BANDWIDTH) |
static shared_ptr< NetServer > | create (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< NetSendConnection > | m_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... | |
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.
|
protected |
|
protected |
G3D::NetServer::~NetServer | ( | ) |
Drop all connections and stop listening for new ones.
|
static |
myAddress | Selects which local adapter and port to listen for incoming connections on |
Referenced by create().
|
inlinestatic |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inline |
Causes the system to check for new incoming connections and then returns an iterator over them.
|
inline |
A connection that sends to all connected clients (not a UDP broadcast to the subnet)
|
protected |
Service the ENetHost, checking for incoming messages and connections and depositing them in the appropriate queues.
Invoked by NetServerSideConnection::serviceHost(), incomingConnectionIterator(), and incomingConnectionIterator().
void G3D::NetServer::stop | ( | ) |
Stop listenening for connections and shut down all clients.
|
friend |
|
friend |
|
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.
|
protected |
|
protected |
|
protected |
Contains the queue.
Referenced by newConnectionIterator().
|
protected |
Referenced by omniConnection().