Defines the interfaces for a client connection.
More...
#include <3esconnection.h>
|
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) |
|
Defines the interfaces for a client connection.
◆ active()
virtual bool tes::Connection::active |
( |
| ) |
const |
|
pure virtual |
◆ address()
virtual const char* tes::Connection::address |
( |
| ) |
const |
|
pure virtual |
Address string for the connection.
The string depends on the connection type.
- Returns
- The connection end point address.
Implemented in tes::CollatedPacket.
◆ create()
virtual int tes::Connection::create |
( |
const Shape & |
shape | ) |
|
|
pure virtual |
Sends a create message for the given shape.
- Parameters
-
- Returns
- The number of bytes queued for transfer for this message, or negative on error. The negative value may be less than -1 and still indicate the successful transfer size.
Implemented in tes::CollatedPacket.
Referenced by tes::Server::~Server().
◆ destroy()
virtual int tes::Connection::destroy |
( |
const Shape & |
shape | ) |
|
|
pure virtual |
Sends a destroy message for the given shape.
- Parameters
-
- Returns
- The number of bytes queued for transfer for this message, or negative on error. The negative value may be less than -1 and still indicate the successful transfer size.
Implemented in tes::CollatedPacket.
◆ isConnected()
virtual bool tes::Connection::isConnected |
( |
| ) |
const |
|
pure virtual |
Is the connection active and valid?
- Returns
- True while connected.
Implemented in tes::CollatedPacket.
◆ port()
virtual uint16_t tes::Connection::port |
( |
| ) |
const |
|
pure virtual |
Get the connection port.
- Returns
- The connection end point port.
Implemented in tes::CollatedPacket.
◆ referenceResource()
virtual unsigned tes::Connection::referenceResource |
( |
const Resource * |
resource | ) |
|
|
pure virtual |
Add a resource to this connection.
The resource is either added with a reference count of 1, or the resource reference count is incremented. The resource
pointer must remain valid until the reference count returns to zero. A newly added resource is pushed into the resource queue for transfer.
- Parameters
-
resource | The resource to reference. |
- Returns
- The resource reference count after adjustment.
Implemented in tes::CollatedPacket.
◆ releaseResource()
virtual unsigned tes::Connection::releaseResource |
( |
const Resource * |
resource | ) |
|
|
pure virtual |
Release a resource within this connection.
If found, the resource has its reference count reduced. A destroy message is sent for the resource if the count becomes zero.
- Parameters
-
resource | The resource to release. |
- Returns
- The resource reference count after adjustment.
Implemented in tes::CollatedPacket.
◆ send() [1/2]
virtual int tes::Connection::send |
( |
const uint8_t * |
data, |
|
|
int |
byteCount |
|
) |
| |
|
pure virtual |
◆ send() [2/2]
int tes::Connection::send |
( |
const int8_t * |
data, |
|
|
int |
byteCount |
|
) |
| |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ setActive()
virtual void tes::Connection::setActive |
( |
bool |
active | ) |
|
|
pure virtual |
Activate/deactivate the connection.
Messages are ignored while inactive.
- Parameters
-
enable | The active state to set. |
Implemented in tes::CollatedPacket.
◆ update()
virtual int tes::Connection::update |
( |
const Shape & |
shape | ) |
|
|
pure virtual |
Sends an update message for the given shape.
- Parameters
-
- Returns
- The number of bytes queued for transfer for this message, or negative on error. The negative value may be less than -1 and still indicate the successful transfer size.
Implemented in tes::CollatedPacket.
◆ updateFrame()
virtual int tes::Connection::updateFrame |
( |
float |
dt, |
|
|
bool |
flush = true |
|
) |
| |
|
pure virtual |
Sends a message marking the end of the current frame (and start of a new frame).
- Parameters
-
dt | Indicates the time passed since over this frame (seconds). |
flush | True to allow clients to flush transient objects, false to instruct clients to preserve such objects. |
- Returns
- The number of bytes queued for transfer for this message, or negative on error. The negative value may be less than -1 and still indicate the successful transfer size.
Implemented in tes::CollatedPacket.
◆ updateTransfers()
virtual int tes::Connection::updateTransfers |
( |
unsigned |
byteLimit | ) |
|
|
pure virtual |
Update any pending resource transfers (e.g., mesh transfer).
Transfer may be amortised by setting a byteLimit
or enforced by a zero byte limit. Zero guarantees all outstanding resources are transferred.
This method should generally be called once for every updateFrame()
, normally before the frame update. This holds especially true when not amortising transfer (zero byte limit).
- Parameters
-
byteLimit | Limit the packet payload size to approximately this amount of data. |
- Returns
- The number of bytes queued for transfer for this message, or negative on error. The negative value may be less than -1 and still indicate the successful transfer size.
Implemented in tes::CollatedPacket.
The documentation for this class was generated from the following file: