Introduction Manual Class Reference Header Reference

The Announcement

The Announcement

An announcement occurs, when the server replicates an object to a client. These announcements are handled in different ways depending on the replicated node's replication mode.

Callback Prototype

We are going to extend the client class from earlier. As you know, many callbacks were left unimplemented there, and here one of these callbacks will get an implementation. Announcements of dynamic nodes can be handled properly as soon as we implemented it.

This is the prototype of the method:

class Client : public ZCom_Control {
    ZCom_cbNodeRequest_Dynamic( ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata,
                                eZCom_NodeRole _role, ZCom_NodeID _net_id ) 

  // all other callback methods omitted here

The parameters to the callback give information about the connection id from which the announcement came (typically always the same id, since there seldomly are connections to several servers at once), the class id, the role which the new node will possess (either eZCom_RoleProxy or eZCom_RoleOwner), the new node's network id and a custom bitstream that can be attached when the node is registered on the server.

Example Callback Implementation

The most important information is the _requested_class parameter. This equals one of the class ids we got by calling ZCom_registerClass() before. We are expected to create one instance of the requested class, so building on top of the Rock and Tree code again, here goes a simple implementation:

void Client::ZCom_cbNodeRequest_Dynamic( 
                   ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata,
                   eZCom_NodeRole _role, ZCom_NodeID _net_id ) 
  if (_requested_class == Tree::getClassID()) 
    // create tree and register it with the client, i.e. 'this'
    Tree* tree = new Tree(this);
  if (_requested_class == Rock::getClassID()) 
    // create rock and register it with the client, i.e. 'this'
    Rock* rock = new Rock(this);

That handles the creation of requested Rocks and Trees. Whenever the server creates one of these and thinks the client should have it, this callback is called, asking the client to create the object and register it's node.

This file is part of the documentation for Zoidcom. Documentation copyright © 2004-2008 by Jörg Rüppel. Generated on Sat Aug 16 15:26:51 2008 for Zoidcom by doxygen 1.4.6-NO