![]() |
||||||||
|
|
||||||||
First, the class needs to be registered with the ZCOM_CLASSFLAG_ANNOUNCEDATA flag.
control->ZCom_registerClass("Rock", ZCOM_CLASSFLAG_ANNOUNCEDATA);
This flag needs to be present in the server and in the client registration of the class.
Second, the data needs to be set with ZCom_Node::setAnnounceData(), on the server only!
node->registerNodeDynamic(control->ZCom_getClassID("Rock"), control); ZCom_BitStream *adata = new ZCom_BitStream(); if (rock_is_black) adata->addString("black"); else adata->addString("grey"); node->setAnnounceData(adata);
Whenever the node gets announced to a client through either ZCom_Control::ZCom_cbNodeRequest_Dynamic() or ZCom_Control::ZCom_cbNodeRequest_Tag(), the data that was set through setAnnounceData() is available in the _announcedata parameter of the two callbacks.
class Client : public ZCom_Control { void ZCom_cbNodeRequest_Dynamic( ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata, eZCom_NodeRole _role, ZCom_NodeID _net_id ) { if (_requested_class == Rock::getClassID()) { const char *color = _announcedata->getStringStatic(); Rock* rock = new Rock(this); // assuming a method like this exists rock->setColor(color); } } // all other callback methods omitted here };
Of course, sending a string to declare a color is a waste of bandwidth. In practice, the data should be compact as possible.
1.4.6-NO