summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
authorfcolin2007-02-01 13:04:06 +0000
committerfcolin2007-02-01 13:04:06 +0000
commita590fa8d95a798b1a4f750ed9b5b85e9e642e701 (patch)
tree18b4824d9f428511afb79e4a3c6158908fb6eec8 /Ivy
parent2ee1ed697edc42aae7962877a5649e2c280741b8 (diff)
downloadivy-cplusplus-a590fa8d95a798b1a4f750ed9b5b85e9e642e701.zip
ivy-cplusplus-a590fa8d95a798b1a4f750ed9b5b85e9e642e701.tar.gz
ivy-cplusplus-a590fa8d95a798b1a4f750ed9b5b85e9e642e701.tar.bz2
ivy-cplusplus-a590fa8d95a798b1a4f750ed9b5b85e9e642e701.tar.xz
Utilisateur : Fcolin Date : 23/05/06 Heure : 18:18 Archivé dans $/Bus/Ivy Commentaire: Modification protocol UDP (vss 15)
Diffstat (limited to 'Ivy')
-rw-r--r--Ivy/IvyWatcher.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/Ivy/IvyWatcher.cxx b/Ivy/IvyWatcher.cxx
index e2a2783..4cbf604 100644
--- a/Ivy/IvyWatcher.cxx
+++ b/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() )