3es  0.7
tes::Server Class Referenceabstract

Defines the interface for managing a 3es server. More...

#include <3esserver.h>

Inheritance diagram for tes::Server:
tes::Connection

Public Member Functions

virtual void dispose ()=0
 Destroys the server this method is called on. This ensures correct clean up.
 
virtual unsigned flags () const =0
 Retrieve the ServerFlag set with which the server was created.
 
virtual int send (const PacketWriter &packet)=0
 Set a completed packet to all clients. More...
 
virtual int send (const CollatedPacket &collated)=0
 Send a collated packet to all clients. More...
 
virtual ConnectionMonitorconnectionMonitor ()=0
 Returns the connection monitor object for this Server. More...
 
virtual unsigned connectionCount () const =0
 Returns the number of current connections. More...
 
virtual Connectionconnection (unsigned index)=0
 Requests the connection at the given index. More...
 
virtual const Connectionconnection (unsigned index) const =0
 
- Public Member Functions inherited from tes::Connection
virtual ~Connection ()
 Virtual destructor.
 
virtual void close ()=0
 Close the socket connection.
 
virtual void setActive (bool active)=0
 Activate/deactivate the connection. More...
 
virtual bool active () const =0
 Check if currently active. More...
 
virtual const char * address () const =0
 Address string for the connection. More...
 
virtual uint16_t port () const =0
 Get the connection port. More...
 
virtual bool isConnected () const =0
 Is the connection active and valid? More...
 
virtual int create (const Shape &shape)=0
 Sends a create message for the given shape. More...
 
virtual int destroy (const Shape &shape)=0
 Sends a destroy message for the given shape. More...
 
virtual int update (const Shape &shape)=0
 Sends an update message for the given shape. More...
 
virtual int updateFrame (float dt, bool flush=true)=0
 Sends a message marking the end of the current frame (and start of a new frame). More...
 
virtual int updateTransfers (unsigned byteLimit)=0
 Update any pending resource transfers (e.g., mesh transfer). More...
 
virtual unsigned referenceResource (const Resource *resource)=0
 Add a resource to this connection. More...
 
virtual unsigned releaseResource (const Resource *resource)=0
 Release a resource within this connection. More...
 
virtual bool sendServerInfo (const ServerInfoMessage &info)=0
 Send server details to the client.
 
virtual int send (const uint8_t *data, int byteCount)=0
 Send pre-prepared message data to all connections. More...
 
int send (const int8_t *data, int byteCount)
 

Static Public Member Functions

static Servercreate (const ServerSettings &settings=ServerSettings(), const ServerInfoMessage *serverInfo=nullptr)
 Creates a server with the given settings. More...
 

Protected Member Functions

virtual ~Server ()
 Hidden virtual destructor.
 

Detailed Description

Defines the interface for managing a 3es server.

Listening must be initiated via the Server object's ConnectionMonitor, available via connectionMonitor(). See that class's comments for details of synchronous and asynchronous operation. The monitor will be null if connections are not supported (generally internal only).

Member Function Documentation

◆ connection() [1/2]

virtual Connection* tes::Server::connection ( unsigned  index)
pure virtual

Requests the connection at the given index.

This data may be stale if the ConnectionMonitor has yet to update.

Parameters
indexThe index of the requested connection.
Returns
The requested connection, or null if index is out of range.

◆ connection() [2/2]

virtual const Connection* tes::Server::connection ( unsigned  index) const
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ connectionCount()

virtual unsigned tes::Server::connectionCount ( ) const
pure virtual

Returns the number of current connections.

Returns
The current number of connections.

◆ connectionMonitor()

virtual ConnectionMonitor* tes::Server::connectionMonitor ( )
pure virtual

Returns the connection monitor object for this Server.

Null if connections are not supported (internal only).

◆ create()

static Server* tes::Server::create ( const ServerSettings settings = ServerSettings(),
const ServerInfoMessage serverInfo = nullptr 
)
static

Creates a server with the given settings.

The settings affect the local server state, while serverInfo describes the server to newly connected clients (first message sent). The serverInfo may be omitted to use the defaults.

Parameters
settingsThe local server settings.
serverInfoServer settings published to clients. Null to use the defaults.

◆ send() [1/2]

virtual int tes::Server::send ( const PacketWriter packet)
pure virtual

Set a completed packet to all clients.

The packet must be finalised first.

Parameters
packetThe packet to send.

◆ send() [2/2]

virtual int tes::Server::send ( const CollatedPacket collated)
pure virtual

Send a collated packet to all clients.

This supports sending collections of packets as a single send operation while maintaining thread safety.

The collated packet may be larger than the normal send limit as collated message is extracted and sent individually. To support this, compression on collated is not supported.

Note sending in this way bypasses the shape and resource caches and
can only work when the user maintains state.
Parameters
collatedCollated packets to send. Compression is not supported.

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