NSM: Clients must use the same protocol (UDP,TCP) as NSM server.

pull/3/head
Jonathan Moore Liles 2012-02-23 20:34:07 -08:00
parent b2affcc5d5
commit f769375a7a
10 changed files with 34 additions and 20 deletions

View File

@ -393,7 +393,7 @@ Mixer::init_osc ( const char *osc_port )
{
osc_endpoint = new OSC::Endpoint();
if ( int r = osc_endpoint->init( osc_port ) )
if ( int r = osc_endpoint->init( LO_UDP, osc_port ) )
return r;
osc_endpoint->owner = this;

View File

@ -229,9 +229,9 @@ main ( int argc, char **argv )
if ( nsm_url )
{
if ( ! nsm->init() )
if ( ! nsm->init( nsm_url ) )
{
nsm->announce( nsm_url, APP_NAME, ":switch:dirty:", argv[0] );
nsm->announce( APP_NAME, ":switch:dirty:", argv[0] );
// poll so we can keep OSC handlers running in the GUI thread and avoid extra sync
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );

View File

@ -60,11 +60,11 @@ namespace NSM
}
void
Client::announce ( const char *nash_url, const char *application_name, const char *capabilities, const char *process_name )
Client::announce ( const char *application_name, const char *capabilities, const char *process_name )
{
MESSAGE( "Announcing to NSM" );
lo_address to = lo_address_new_from_url( nash_url );
lo_address to = lo_address_new_from_url( nsm_url );
if ( ! to )
{
@ -151,9 +151,15 @@ namespace NSM
}
int
Client::init ( )
Client::init ( const char *nsm_url )
{
_server = lo_server_new( NULL, NULL );
this->nsm_url = nsm_url;
lo_address addr = lo_address_new_from_url( nsm_url );
int proto = lo_address_get_protocol( addr );
lo_address_free( addr );
_server = lo_server_new_with_proto( NULL, proto, NULL );
if ( ! _server )
return -1;
@ -169,9 +175,15 @@ namespace NSM
}
int
Client::init_thread ( )
Client::init_thread ( const char *nsm_url )
{
_st = lo_server_thread_new( NULL, NULL );
this->nsm_url = nsm_url;
lo_address addr = lo_address_new_from_url( nsm_url );
int proto = lo_address_get_protocol( addr );
lo_address_free( addr );
_st = lo_server_thread_new_with_proto( NULL, proto, NULL );
_server = lo_server_thread_get_server( _st );
if ( ! _server || ! _st )

View File

@ -29,6 +29,8 @@ namespace NSM
private:
const char *nsm_url;
lo_server _server;
lo_server_thread _st;
lo_address nsm_addr;
@ -64,14 +66,14 @@ namespace NSM
void is_clean ( void );
void progress ( float f );
void message( int priority, const char *msg );
void announce ( const char *nsm_url, const char *appliction_name, const char *capabilities, const char *process_name );
void announce ( const char *appliction_name, const char *capabilities, const char *process_name );
void broadcast ( lo_message msg );
/* init without threading */
int init ( void );
int init ( const char *nsm_url );
/* init with threading */
int init_thread ( void );
int init_thread ( const char *nsm_url );
/* call this periodically to check for new messages */
void check ( int timeout = 0 );

View File

@ -87,11 +87,11 @@ namespace OSC
}
int
Endpoint::init ( const char *port )
Endpoint::init ( int proto, const char *port )
{
DMESSAGE( "Creating OSC server" );
_server = lo_server_new( port, error_handler );
_server = lo_server_new_with_proto( port, proto, error_handler );
if ( ! _server )
{

View File

@ -270,7 +270,7 @@ namespace OSC
void list_peers ( void (*callback) (const char *, const char *, int, void * ), void *v );
int init ( const char *port = 0 );
int init ( int proto, const char *port = 0 );
Endpoint ( );
~Endpoint ( );

View File

@ -1801,7 +1801,7 @@ int main(int argc, char *argv[])
osc_server = new OSC::Endpoint();
if ( osc_server->init( osc_port ) )
if ( osc_server->init( LO_UDP, osc_port ) )
{
FATAL( "Failed to create OSC server." );
}

View File

@ -668,7 +668,7 @@ public:
{
osc = new OSC::Endpoint();
if ( int r = osc->init() )
if ( int r = osc->init( LO_UDP ) )
return r;
osc->owner = this;

View File

@ -1571,7 +1571,7 @@ Timeline::init_osc ( const char *osc_port )
{
osc = new OSC::Endpoint();
if ( int r = osc->init( osc_port ) )
if ( int r = osc->init( LO_UDP, osc_port ) )
return r;
osc->owner = this;

View File

@ -207,9 +207,9 @@ main ( int argc, char **argv )
if ( nsm_url )
{
if ( ! nsm->init() );
if ( ! nsm->init( nsm_url ) );
{
nsm->announce( nsm_url, APP_NAME, ":progress:switch:", argv[0] );
nsm->announce( APP_NAME, ":progress:switch:", argv[0] );
/* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );