TrinityCore
|
#include <NetworkDevice.h>
Public Member Functions | |
virtual | ~Conduit () |
uint64 | bytesSent () const |
uint64 | messagesSent () const |
uint64 | bytesReceived () const |
uint64 | messagesReceived () const |
virtual bool | messageWaiting () |
virtual uint32 | waitingMessageType ()=0 |
bool | ok () const |
Public Member Functions inherited from G3D::ReferenceCountedObject | |
virtual | ~ReferenceCountedObject () |
Protected Member Functions | |
Conduit () | |
Protected Attributes | |
uint64 | mSent |
uint64 | mReceived |
uint64 | bSent |
uint64 | bReceived |
SOCKET | sock |
BinaryOutput | binaryOutput |
Friends | |
class | NetworkDevice |
class | NetListener |
|
protected |
|
virtual |
uint64 G3D::Conduit::bytesReceived | ( | ) | const |
uint64 G3D::Conduit::bytesSent | ( | ) | const |
uint64 G3D::Conduit::messagesReceived | ( | ) | const |
uint64 G3D::Conduit::messagesSent | ( | ) | const |
|
virtual |
If true, receive will return true.
Reimplemented in G3D::LightweightConduit, and G3D::ReliableConduit.
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; ... }
Implemented in G3D::LightweightConduit, and G3D::ReliableConduit.
|
friend |
|
friend |
|
protected |
Used for serialization. One per socket to make this threadsafe.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |