2 /*******************************************************************************/
3 /* Copyright (C) 2010 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
23 #include <OSC/Endpoint.H>
29 static bool got_response = false;
31 /************************/
32 /* OSC Message Handlers */
33 /************************/
35 static int osc_reply ( const char *path, const char *types, lo_arg **argv, int argc, lo_message, void * )
39 printf( "%s : ", path );
41 for ( int i = 0; i < argc; ++i )
46 printf( "\"%s\" ", &argv[i]->s );
49 printf( "%f ", argv[i]->f );
52 printf( "%i ", argv[i]->i );
66 int main(int argc, char *argv[])
72 s.add_method( NULL, NULL, osc_reply, 0, "");
74 std::list<OSC::OSC_Value> args;
76 for ( int i = 3; i < argc; ++i )
78 const char *s = argv[i];
80 if ( strspn( s, "+-0123456789" ) == strlen( s ) )
82 args.push_back( OSC::OSC_Int( atol( s ) ) );
84 else if ( strspn( s, ".+-0123456789" ) == strlen( s ) )
85 args.push_back( OSC::OSC_Float( atof( s ) ) );
88 args.push_back( OSC::OSC_String( s ) );
92 lo_address t = lo_address_new_from_url( argv[1] );
94 fprintf( stderr, "Sending to %s\n", argv[1] );
96 s.send( t, argv[2], args );
98 printf( "Waiting for reply...\n" );
100 while ( ! got_response )