GNE::ObjectBrokerServer Class Reference
[High-Level API]

The ObjectBrokerServer assigns IDs to NetworkObject objects, and aids in the creation of ObjectBrokerPacket packets. More...

#include <ObjectBrokerServer.h>

Inheritance diagram for GNE::ObjectBrokerServer:

Inheritance graph
[legend]
Collaboration diagram for GNE::ObjectBrokerServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ObjectBrokerServer ()
 Creates a new ObjectBrokerServer Object with no taken IDs.
 ~ObjectBrokerServer ()
 Dtor.
ObjectCreationPacket::sptr getCreationPacket (NetworkObject &obj)
 Method for registering a new object, or getting a creation packet from an already registered object.
ObjectUpdatePacket::sptr getUpdatePacket (NetworkObject &obj, const void *param)
 Returns an ObjectUpdatePacket for the given object.
ObjectUpdatePacket::sptr getUpdatePacket (NetworkObject &obj)
 Same as ObjectBrokerServer::getUpdatePacket( NetworkObject&, const void* ), but passes in NULL as the const void* parameter.
ObjectDeathPacket::sptr getDeathPacket (NetworkObject &obj)
 Creates an ObjectDeathPacket for the given object, but does NOT unregister the object, in case additional death packets need to be created (to send to other, multiple clients).

Detailed Description

The ObjectBrokerServer assigns IDs to NetworkObject objects, and aids in the creation of ObjectBrokerPacket packets.

When a new object is registered with the broker, a new, unique, ID is assigned to that NetworkObject and that ID is marked as a taken ID until it is unregistered.

The packets that the ObjectBrokerServer returns about a particular object must be sent to the clients in the same order that ObjectBrokerServer gives them to you based on the API calls. This is fairly self-evident, but this means that the ObjectCreationPacket must be sent before ObjectUpdatePacket packets and those before ObjectDeathPacket packets. In order to guarantee this, the creation and death packets must be sent reliably. Update packets may be sent unreliably, but you must be prepared for the scenario that the update packet arrives before the creation packet, and will probably need to be ignored. This is possible because the reliable and unreliable packet streams in GNE may be unrelated, and have no guaranteed order in relation to each other.

There are 65535 available object IDs, so you cannot have more objects than that.

Almost all methods return a smart pointer to a packet, which means you do not need worry about memory allocation.


Member Function Documentation

ObjectCreationPacket::sptr GNE::ObjectBrokerServer::getCreationPacket ( NetworkObject obj  ) 

Method for registering a new object, or getting a creation packet from an already registered object.

If the given object has an ID, a new ObjectCreationPacket is generated. A new ID is assigned automatically if the given object does not have an ID.

If no IDs remain because there are too many objects, then a NULL pointer is returned.

ObjectDeathPacket::sptr GNE::ObjectBrokerServer::getDeathPacket ( NetworkObject obj  ) 

Creates an ObjectDeathPacket for the given object, but does NOT unregister the object, in case additional death packets need to be created (to send to other, multiple clients).

Parameters:
obj a valid NetworkObject (one that has been assigned a valid ID through getCreationPacket).

ObjectUpdatePacket::sptr GNE::ObjectBrokerServer::getUpdatePacket ( NetworkObject obj  ) 

Same as ObjectBrokerServer::getUpdatePacket( NetworkObject&, const void* ), but passes in NULL as the const void* parameter.

Parameters:
obj a valid NetworkObject (one that has been assigned a valid ID through getCreationPacket).

ObjectUpdatePacket::sptr GNE::ObjectBrokerServer::getUpdatePacket ( NetworkObject obj,
const void *  param 
)

Returns an ObjectUpdatePacket for the given object.

The passed parameter, param, is passed directly into the NetworkObject's createUpdatePacket method.

See also:
NetworkObject::createUpdatePacket


The documentation for this class was generated from the following files:
Generated on Tue Sep 5 23:47:49 2006 for GNE by  doxygen 1.4.7