summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:51:47 +0000
committerfcolin2007-02-01 09:51:47 +0000
commitf0ef4c61358525c2d3f7320c83bc22ffe3d62d63 (patch)
treecd33893c2cfee5c4ba06eea96f5174d23703dced /CSharp
parent77ccd326df0480088cf2f41cc104214b24c4aa5b (diff)
downloadivy-csharp-f0ef4c61358525c2d3f7320c83bc22ffe3d62d63.zip
ivy-csharp-f0ef4c61358525c2d3f7320c83bc22ffe3d62d63.tar.gz
ivy-csharp-f0ef4c61358525c2d3f7320c83bc22ffe3d62d63.tar.bz2
ivy-csharp-f0ef4c61358525c2d3f7320c83bc22ffe3d62d63.tar.xz
Utilisateur : Fcolin Date : 6/02/06 Heure : 17:12 Archivé dans $/CSharp/Ivy/Ivy Commentaire: utilisation generale de traceDEbug et System.Diagnostics (vss 16)
Diffstat (limited to 'CSharp')
-rw-r--r--CSharp/Ivy/Ivy/IvyWatcher.cs36
1 files changed, 20 insertions, 16 deletions
diff --git a/CSharp/Ivy/Ivy/IvyWatcher.cs b/CSharp/Ivy/Ivy/IvyWatcher.cs
index d61bafd..47b2239 100644
--- a/CSharp/Ivy/Ivy/IvyWatcher.cs
+++ b/CSharp/Ivy/Ivy/IvyWatcher.cs
@@ -15,6 +15,7 @@ namespace IvyBus
using System.Text.RegularExpressions;
using System.Configuration;
using System.Text;
+ using System.Diagnostics;
/// <summary> IvyWatcher, A private Class for the Ivy rendezvous
/// </summary>
@@ -81,7 +82,7 @@ namespace IvyBus
/// </summary>
public void Run()
{
- bus.traceDebug("beginning of a watcher Thread");
+ traceDebug("beginning of a watcher Thread");
try
{
@@ -99,13 +100,13 @@ namespace IvyBus
stream.receiveMsg(out remoteEP, out version,out port,out appId,out appName);
IPAddress remotehost = remoteEP.Address;
- bus.traceDebug("BUSWATCHER Receive Broadcast from " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port);
+ traceDebug("BUSWATCHER Receive Broadcast from " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port);
//TODO if ( !isInDomain( remotehost ) ) continue;
if (version != stream.ProtocolVersion)
{
- Console.Error.WriteLine("Ignoring bad protocol version {0} expected {1}", version, stream.ProtocolVersion);
+ traceDebug("Ignoring bad protocol version "+ version + " expected " + stream.ProtocolVersion);
continue;
}
@@ -115,7 +116,7 @@ namespace IvyBus
if ( (port == bus.applicationPort) && (remotehost.Equals(bus.applicationHost)) )
continue;
- bus.traceDebug("BUSWATCHER reponse au Broadcast de " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port + " port " + port +
+ traceDebug("BUSWATCHER reponse au Broadcast de " + Dns.GetHostEntry(remotehost).HostName + ":" + remoteEP.Port + " port " + port +
" version " + version +
" id " + appId +
" name " + appName);
@@ -128,12 +129,12 @@ namespace IvyBus
}
catch (Exception e)
{
- Console.Error.WriteLine("can't connect to " + remotehost + " port " + port + " \n" + e.Message);
+ traceDebug("can't connect to " + remotehost + " port " + port + " \n" + e.Message);
}
}
catch (IOException jii)
{
- Console.Error.WriteLine("UDP listener " + jii.Message);
+ traceDebug("UDP listener " + jii.Message);
running = false;
}
// catch (SocketException se)
@@ -144,13 +145,13 @@ namespace IvyBus
}
catch (SocketException se)
{
- bus.traceDebug("watcher socket closed: " + se.Message);
+ traceDebug("watcher socket closed: " + se.Message);
}
catch (IOException ioe)
{
- bus.traceDebug("watcher thread ended: " + ioe.Message);
+ traceDebug("watcher thread ended: " + ioe.Message);
}
- bus.traceDebug("end of a watcher thread");
+ traceDebug("end of a watcher thread");
}
/// <summary> stops the thread waiting on the broadcast socket
@@ -159,7 +160,7 @@ namespace IvyBus
{
lock(this)
{
- bus.traceDebug("begining stopping an IvyWatcher");
+ traceDebug("begining stopping an IvyWatcher");
stream.Close();
if (listenThread != null)
{
@@ -167,7 +168,7 @@ namespace IvyBus
listenThread = null;
}
// it might not even have been created
- bus.traceDebug("ending stopping an IvyWatcher");
+ traceDebug("ending stopping an IvyWatcher");
}
}
@@ -197,10 +198,9 @@ namespace IvyBus
}
catch (ArgumentException e)
{
- Console.Error.WriteLine("Bad broascat addr " + net + "error " + e.Message);
+ traceDebug("Bad broascat addr " + net + "error " + e.Message);
return null;
}
- // out.println("net: "+net);
return net;
}
@@ -208,9 +208,13 @@ namespace IvyBus
{
int sep_index = net.LastIndexOf(":");
int port = (sep_index == - 1)?Ivy.DEFAULT_PORT:Int32.Parse(net.Substring(sep_index + 1));
- // Console.Error.Writeline("net: ["+net+"]\nsep_index: "+sep_index+"\nport: "+port);
- return port;
- }
+ return port;
+ }
+ [Conditional("DEBUG")]
+ private static void traceDebug(string s)
+ {
+ Trace.WriteLineIf(Ivy.VerboseDebug, "-->ivywatcher<-- " + s);
+ }
}
// class IvyWatcher