string toString(osc::Message const& m) { stringstream s; s << '[' << m.getAddress() << ' '; for (int i=0; i<m.getNumArgs(); ++i) { s << m.getArgAsString(i, true); } s << ']'; return s.str(); }
/** * Log incomming OSC msgs * Taken from OSCListener example provided with the Cinder OSC block */ void OSCController::__logMessage( osc::Message msg ) { if( displayMsgLog ){ console() << "Incomming OSC msg: @ " << getId() << std::endl; console() << "Address: " << msg.getAddress() << std::endl; if( displayMsgExtended ){ console() << "Num Arg: " << msg.getNumArgs() << std::endl; for (int i = 0; i < msg.getNumArgs(); i++) { console() << "-- Argument " << i << std::endl; console() << "---- type: " << msg.getArgTypeName(i) << std::endl; if (msg.getArgType(i) == osc::TYPE_INT32){ try { console() << "------ value: "<< msg.getArgAsInt32(i) << std::endl; } catch (...) { console() << "Exception reading argument as int32" << std::endl; } }else if (msg.getArgType(i) == osc::TYPE_FLOAT){ try { console() << "------ value: " << msg.getArgAsFloat(i) << std::endl; } catch (...) { console() << "Exception reading argument as float" << std::endl; } }else if (msg.getArgType(i) == osc::TYPE_STRING){ try { console() << "------ value: " << msg.getArgAsString(i).c_str() << std::endl; } catch (...) { console() << "Exception reading argument as string" << std::endl; } } } } } }
void PluginOSCController::processInteralMessage( const osc::Message& message, vector<string> tokens ){ return; console() << "========= INTERNAL MESSAGE ==========" << std::endl; console() << "Num Arg: " << message.getNumArgs() << std::endl; for (int i = 0; i < message.getNumArgs(); i++) { console() << "-- Argument " << i << std::endl; console() << "---- type: " << message.getArgTypeName(i) << std::endl; if( message.getArgType(i) == osc::TYPE_INT32 ) { try { console() << "------ value: "<< message.getArgAsInt32(i) << std::endl; } catch (...) { console() << "Exception reading argument as int32" << std::endl; } } else if( message.getArgType(i) == osc::TYPE_FLOAT ) { try { console() << "------ value: " << message.getArgAsFloat(i) << std::endl; } catch (...) { console() << "Exception reading argument as float" << std::endl; } } else if( message.getArgType(i) == osc::TYPE_STRING) { try { console() << "------ value: " << message.getArgAsString(i).c_str() << std::endl; } catch (...) { console() << "Exception reading argument as string" << std::endl; } } } }