Support Forum G3D Web Page |
Inherits G3D::ReferenceCountedObject.
Public Member Functions | |
virtual | ~Conduit () |
uint64 | bytesReceived () const |
uint64 | bytesSent () const |
uint64 | messagesReceived () const |
uint64 | messagesSent () const |
virtual bool | messageWaiting () |
If true, receive will return true. More... | |
bool | ok () const |
Returns true if the connection is ok. More... | |
virtual uint32 | waitingMessageType ()=0 |
Returns the type of the waiting message (i.e. More... | |
Protected Member Functions | |
Conduit () | |
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 | |
BinaryOutput | binaryOutput |
Used for serialization. More... | |
uint64 | bReceived |
uint64 | bSent |
uint64 | mReceived |
uint64 | mSent |
SOCKET | sock |
Friends | |
class | NetListener |
class | NetworkDevice |
|
protected |
|
virtual |
uint64 G3D::Conduit::bytesReceived | ( | ) | const |
uint64 G3D::Conduit::bytesSent | ( | ) | const |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
uint64 G3D::Conduit::messagesReceived | ( | ) | const |
uint64 G3D::Conduit::messagesSent | ( | ) | const |
|
virtual |
If true, receive will return true.
bool G3D::Conduit::ok | ( | ) | const |
Returns true if the connection is ok.
|
pure virtual |
Returns the type of the waiting message (i.e.
the type supplied with send). The return value is zero when there is no message waiting.
One way to use this is to have a Table mapping message types to pre-allocated subclasses so receiving looks like:
// My base class for messages. class Message { virtual void serialize(BinaryOutput&) const; virtual void deserialize(BinaryInput&); virtual void process() = 0; };
Message* m = table[conduit->waitingMessageType()]; conduit->receive(m); m->process();
Another is to simply switch on the message type:
switch (conduit->waitingMessageType()) { case 0: // No message break;
case ENTITY_SPAWN_MSG: { EntitySpawnMsg m; condiut->receive(m); spawnEntity(m.id, m.position, m.modelID); } break; ... }
|
friend |
|
friend |
|
protected |
Used for serialization.
One per socket to make this threadsafe.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |