Example #1
0
void CFellow::PublishAndSubscribe()
{
    if (ms_rtiAmb)
    {
        RTI::AttributeHandleSet *fellowAttrs;
        try
        {
            fellowAttrs = RTI::AttributeHandleSetFactory::create(3);
            fellowAttrs->add(ms_hFellowName);
            fellowAttrs->add(ms_hFellowColor);
            fellowAttrs->add(ms_hFellowPortrait);
        }
        catch (RTI::Exception& e)
        {
            AfxMessageBox((CString)e._name);
        }

        try
        {
            ms_rtiAmb->subscribeObjectClassAttributes(ms_hFellow, *fellowAttrs);
            ms_rtiAmb->publishObjectClass(ms_hFellow, *fellowAttrs);
        }
        catch (RTI::Exception& e)
        {
            AfxMessageBox((CString)e._name);
        }

        fellowAttrs->empty();
        delete fellowAttrs;
    }
}
Example #2
0
//-----------------------------------------------------------------
//
// METHOD:
//     void Country::PublishAndSubscribe()
//
// PURPOSE:
//     Publishes and Subscribes to Object & Interaction classes
//     and their member data.
//
//     Note: In most reasonable applications this would be broken
//           up into 2 different methods.
//
// RETURN VALUES:
//     None. 
//
// HISTORY:
//     1) Created 11/6/96
//     2) Updated to RTI 1.3 3/26/98
//
//-----------------------------------------------------------------
void Country::PublishAndSubscribe()
{
   if ( ms_rtiAmb )
   {
      //------------------------------------------------------
      // To actually subscribe and publish we need to build
      // an AttributeHandleSet that contains a list of
      // attribute type ids (AttributeHandle).
      //------------------------------------------------------
      RTI::AttributeHandleSet *countryAttributes;
      countryAttributes = RTI::AttributeHandleSetFactory::create(2);

      countryAttributes->add( ms_nameTypeId );
      countryAttributes->add( ms_popTypeId );

      ms_rtiAmb->subscribeObjectClassAttributes( ms_countryTypeId,
                                                *countryAttributes );
      ms_rtiAmb->publishObjectClass( ms_countryTypeId,
                                     *countryAttributes);

      countryAttributes->empty();

      delete countryAttributes;   // Deallocate the memory

      //------------------------------------------------------
      // Same as above for interactions
      //------------------------------------------------------

      // Get RTTI info
      ms_commTypeId    = ms_rtiAmb->getInteractionClassHandle( ms_commTypeStr );

      ms_commMsgTypeId = ms_rtiAmb->getParameterHandle( ms_commMsgTypeStr,
                                                        ms_commTypeId);

      // Declare my Interaction interests
      ms_rtiAmb->subscribeInteractionClass( ms_commTypeId );
      ms_rtiAmb->publishInteractionClass( ms_commTypeId );
   }
}