![]() |
||||||||
|
|
||||||||
Now this is what they can do, but what are they good for? A few things come to mind:
class MyInterceptor : public ZCom_NodeReplicationInterceptor { void outPreReplicateNode(ZCom_Node *_node, ZCom_ConnID _to, eZCom_NodeRole _remote_role) {} void outPreDereplicateNode(ZCom_Node *_node, ZCom_ConnID _to, eZCom_NodeRole _remote_role) {} bool outPreUpdate(ZCom_Node *_node, ZCom_ConnID _to, eZCom_NodeRole _remote_role) { return true; } bool outPreUpdateItem(ZCom_Node *_node, ZCom_ConnID _to, eZCom_NodeRole _remote_role, ZCom_Replicator *_replicator) { return true; } void outPostUpdate(ZCom_Node *_node, ZCom_ConnID _to, eZCom_NodeRole _remote_role, zU32 _rep_bits, zU32 _event_bits, zU32 _meta_bits) {} bool inPreUpdate(ZCom_Node *_node, ZCom_ConnID _from, eZCom_NodeRole _remote_role) { return true; } bool inPreUpdateItem(ZCom_Node *_node, ZCom_ConnID _from, eZCom_NodeRole _remote_role, ZCom_Replicator *_replicator, zU32 _estimated_time_sent) { return true; } void inPostUpdate(ZCom_Node *_node, ZCom_ConnID _from, eZCom_NodeRole _remote_role, zU32 _rep_bits, zU32 _event_bits, zU32 _meta_bits) {} };
I won't describe the semantics of all the callbacks here now, you can easily read that up here: ZCom_NodeReplicationInterceptor. Just let me explain the common parameters:
The two *PreUpdateItem() callbacks give you detailed information about single replicators sending or receiving updates. They do not get called by default, however. To activate them, you have to give an additional flag to the replicator during registration. This flag is ZCOM_REPFLAG_INTERCEPT and should be ORed (|) together with any other flag you might find useful for that replicator. The most important piece of information is the pointer to the source/target replicator. Issueing a _replicator->getPeekData() call will peek into the update and return the data to the interceptor.
After deriving your class and creating an object from it, you can register the interceptor object with any node you wish through ZCom_Node::setReplicationInterceptor. From then on, the in* callbacks get called from within ZCom_processInput(), while the out* callbacks will get called from ZCom_processOutput() respectively.
1.4.6-NO