summaryrefslogtreecommitdiff
path: root/Bus/Ivy/IvyWatcher.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Bus/Ivy/IvyWatcher.cxx')
-rw-r--r--Bus/Ivy/IvyWatcher.cxx21
1 files 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() )