VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Test Interaction application

Once we build the TestInteraction class, and outfit it with a TestEncoder and TestDecoder, we can use it in an application just like any other DtInteraction subclass.

In testInterMain.cxx, we create a TestInteraction, fill it out, and send it. We also register a callback on incoming TestInteractions, and print their contents using the virtual printData() function.

After you build the testInter example, run two copies of it. You should see them communicating with each other. Each should print TestInteractions received from the other.


/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include "testInter.h"
#include <iostream>
// Callback function to be called when a TestInteraction is received.
void testCb(TestInteraction* inter, void*)
{
std::cout << "Received Test Interaction!\n";
inter->print();
std::cout << std::endl;
}
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "InterTest" );
DtExerciseConn conn("example-vrlExtend", "TestInter", (DtFomMapper*) NULL);
DtClock* clock = conn.clock();
// Register the callback on incoming TestInteractions.
TestInteraction::addCallback(&conn, testCb, NULL);
while (1)
{
clock->setSimTime(clock->absRealTime());
conn.drainInput();
// Send a TestInteraction.
TestInteraction inter;
inter.setNumber(10);
inter.setVector(DtVector(1.0, 2.0, 3.0));
conn.sendStamped(inter);
DtSleep(1.0);
}
return 0;
}

Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)