Example #1
0
void Client::send( const osc::Message &message )
{
	lo_message msg = lo_message_new();

	for ( size_t i = 0; i < message.getNumArgs(); i++ )
	{
		switch ( message.getArgType( i ) )
		{
			case 'i':
				lo_message_add_int32( msg, message.getArg< int32_t >( i ) );
				break;

			case 'f':
				lo_message_add_float( msg, message.getArg< float >( i ) );
				break;

			case 's':
				lo_message_add_string( msg, message.getArg< std::string >( i ).c_str() );
				break;

			default:
				break;
		}
	}

	lo_send_message( mAddress, message.getAddressPattern().c_str(), msg );
	lo_message_free( msg );
}
Example #2
0
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;
            }
        }
    }
    
}