//-*-c++-*- #ifndef _RemoteButtonEvent_h_ #define _RemoteButtonEvent_h_ #include #include "Behaviors/StateMachine.h" #include "Shared/string_util.h" #nodeclass RemoteButtonEvent : StateNode #nodeclass SetupListener : StateNode : doStart //this code goes on the listening robot const TextMsgEvent &textev = dynamic_cast(*event); unsigned int x; int const result = sscanf(textev.getText().c_str(), "%u.%u.%u.%u", &x, &x, &x, &x); if ( result != 4 ) { std::cout << "Invalid IP address" << std::endl; postStateFailure(); return; } int ip = string_util::stringToIntIP(textev.getText()); erouter->addRemoteListener(this, ip, EventBase::buttonEGID); sndman->speak("Listening for remote events"); #nodemethod doEvent std::cout << "Remote event: " << event->getDescription() << std::endl; erouter->postEvent(EventBase(EventBase::userEGID, event->getSourceID(), EventBase::activateETID)); #endnodeclass #nodeclass DoSomething : StateNode : doStart //whatever your demo does //to get the listening robot to execute erouter->postEvent(EventBase(EventBase::buttonEGID,1, EventBase::activateETID)); #endnodeclass #nodemethod setup #statemachine startnode: StateNode =TM=> SetupListener =C=> listen listen: StateNode =E(userEGID)=> SoundNode($,"ping.wav") =N=> listen #endstatemachine #endnodeclass #endif