Example #1
0
void
av::NetNodeServer::cast(av::Msg& av_msg)
{
  zmq::message_t zmq_message(av_msg.getSize());
  memcpy(zmq_message.data(), av_msg.getBuffer(), av_msg.getSize());
  mSocket.send(zmq_message);
}
Example #2
0
void
av::NetNode::setStateFragment(const std::string& fragment, av::Msg& stateMsg)
{
#ifdef AVANGO_DEBUG
  logger.debug()<< "av::NetNode::set_state_fragment: from "
                    << fragment << " size: "
                    << stateMsg.getSize() << " bytes.";
#endif

  // this is for the Maestro_Merge_Simple test
  if (mObjectMap.slotExists(fragment))
  {
    return;
  }

  // we need to reset our old state fragment before we receive the new state fragment
  if (mObjectMap.slotExists(fragment))
  {
    mObjectMap.emptySlot(fragment);
  } else
  {
    mObjectMap.addSlot(fragment);
  }

  // decode the state message
  Msg sm(stateMsg);
  sm.setNetNode(this);

  // first the creations
  int num_objects, i;

  av_popMsg(sm, num_objects);

#ifdef AVANGO_DEBUG
  logger.debug()<< "av::NetNode::set_state_fragment: create messages: "
                    << num_objects;
#endif

  for (i=0; i<num_objects; ++i)
  {
    consumeMessage(sm);
  }
  // then the updates
  av_popMsg(sm, num_objects);

#ifdef AVANGO_DEBUG
  logger.debug()<< "av::NetNode::set_state_fragment: update messages: "
                    << num_objects;
#endif

  for (i=0; i<num_objects; ++i)
  {
    consumeMessage(sm);
  }

#ifdef AVANGO_DEBUG
  logger.debug()<< "av::NetNode::set_state_fragment: setting state fragment for "
                    << fragment;
#endif

  // finally whatever the client needs
  _setStateFragment(fragment, sm);
}