From 4a1b96fbe90da988f2fa19fe298f29e918e154dc Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:04:06 +0000 Subject: Utilisateur : Fcolin Date : 23/05/06 Heure : 18:18 Archivé dans $/Bus/Ivy Commentaire: Modification protocol UDP (vss 15) --- Bus/Ivy/IvyWatcher.cxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Bus/Ivy/IvyWatcher.cxx b/Bus/Ivy/IvyWatcher.cxx index e2a2783..4cbf604 100644 --- a/Bus/Ivy/IvyWatcher.cxx +++ b/Bus/Ivy/IvyWatcher.cxx @@ -30,12 +30,16 @@ void IvyWatcher::OnReceive(int nErrorCode) { size_t err; int version; - char buffer[256]; + char buffer[2048]; ivy::string remotehost; UINT remoteport; UINT serviceport; + char appid[2048]; + char appname[2048]; - + memset( appid, 0, sizeof( appid ) ); + memset( appname, 0, sizeof( appname ) ); + err = ReceiveFrom( buffer, sizeof(buffer), remotehost, remoteport ); if ( err == SOCKET_ERROR ) { @@ -43,8 +47,8 @@ void IvyWatcher::OnReceive(int nErrorCode) return; } if ( err < 255 ) buffer[err] ='\0'; - err = sscanf_s(buffer,"%d %u",&version, &serviceport); - if ( err != 2 ) + err = sscanf_s(buffer,"%d %u %s %[^\n]",&version, &serviceport,appid, sizeof(appid), appname,sizeof(appname)); + if ( err < 2 ) { /* ignore the message */ TRACE(" Bad Supervision message expected 'version port'\n"); @@ -56,6 +60,9 @@ void IvyWatcher::OnReceive(int nErrorCode) TRACE(" Bad Ivy verion number expected %d receive %d from %s:%d\n", VERSION,version, remotehost.c_str(), remoteport); return; } + /* check if we received our own message. SHOULD ALSO TEST THE HOST */ + if ( strcmp( appid , bus->ApplicationID.c_str()) ==0 ) return; + /* check if we receive our own message should test also the host */ if ( serviceport == bus->GetApplicationPort() /*&& remotehost == "localhost"*/) return; TRACE(" Broadcast de %s:%u port %u\n", remotehost.c_str(), remoteport, serviceport ); @@ -63,7 +70,7 @@ void IvyWatcher::OnReceive(int nErrorCode) /* connect to the service and send the regexp */ IvyApplication *newapp = new IvyApplication(bus); // exception to catch - newapp->Create(remotehost.c_str(), serviceport); + newapp->Create(remotehost.c_str(), serviceport, appname ); // delete newapp; // return; @@ -96,8 +103,8 @@ void IvyWatcher::start(const char *domainlist) StartListener(); ivy::string addr; - char hello[1024]; - int len = _snprintf_s( hello, sizeof(hello), sizeof(hello)-1, "%d %u\n", VERSION, bus->GetApplicationPort() ); + char hello[2048]; + int len = _snprintf_s( hello, sizeof(hello), sizeof(hello)-1, "%d %u %s %s\n", VERSION, bus->GetApplicationPort(), bus->ApplicationID.c_str(), bus->ApplicationName.c_str() ); // send broadcast to domain list while ( !domain.empty() ) -- cgit v1.1