From b248078ec6f9db57e7320b36d1718040266d8c37 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 10:03:28 +0000 Subject: Utilisateur : Fcolin Date : 19/12/05 Heure : 16:54 Archivé dans $/CSharp/Ivy Commentaire: (vss 12) --- CSharp/Ivy/IvyPPC/IvyWatcher.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/CSharp/Ivy/IvyPPC/IvyWatcher.cs b/CSharp/Ivy/IvyPPC/IvyWatcher.cs index fd7f0ff..d5141f3 100644 --- a/CSharp/Ivy/IvyPPC/IvyWatcher.cs +++ b/CSharp/Ivy/IvyPPC/IvyWatcher.cs @@ -31,7 +31,7 @@ namespace IvyBus private int port; private volatile Thread listenThread; private IPAddress group; - private IvyUDPStreamV4 stream; + private IvyUDPStream stream; /// creates an Ivy watcher /// @@ -65,7 +65,11 @@ namespace IvyBus { broadcast.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.AddMembership, new MulticastOption( group )); } - stream = new IvyUDPStreamV4(broadcast); + // TODO support the Two protocol + if (Properties.Settings.Default.IvyProtocolVersion == 4) + stream = new IvyUDPStreamV4(broadcast); + else + stream = new IvyUDPStreamV3(broadcast); } catch (IOException e) { @@ -86,9 +90,9 @@ namespace IvyBus { try { - - int version; - int port; + + ushort version; + ushort port; string appId; string appName; IPEndPoint remoteEP; @@ -99,14 +103,18 @@ namespace IvyBus //TODO if ( !isInDomain( remotehost ) ) continue; - if (version != IvyUDPStreamV4.PROCOCOLVERSION) + if (version != stream.ProtocolVersion) { - Console.Error.WriteLine("Ignoring bad protocol version {0} expected {1}", version, IvyUDPStreamV4.PROCOCOLVERSION); + Console.WriteLine("Ignoring bad protocol version {0} expected {1}", version, stream.ProtocolVersion); continue; } - - if ( appId == bus.AppId ) // self Broadcast + + // filtrage des self Broadcast + if ( appId == bus.AppId ) continue; + if ( (port == bus.applicationPort) && (remotehost.Equals(bus.applicationHost)) ) + continue; + traceDebug("BUSWATCHER Broadcast de " + Dns.GetHostByAddress(remotehost).HostName + ":" + remoteEP.Port + " port " + port + " version " + version + " id " + appId + @@ -200,7 +208,7 @@ namespace IvyBus { int sep_index = net.LastIndexOf(":"); int port = (sep_index == - 1)?Ivy.DEFAULT_PORT:Int32.Parse(net.Substring(sep_index + 1)); - // out.println("net: ["+net+"]\nsep_index: "+sep_index+"\nport: "+port); + // Console.Writeline("net: ["+net+"]\nsep_index: "+sep_index+"\nport: "+port); return port; } -- cgit v1.1