summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyWatcher.cs28
1 files 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;
/// <summary> creates an Ivy watcher
/// </summary>
@@ -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;
}