diff options
author | fcolin | 2007-02-01 10:03:36 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 10:03:36 +0000 |
commit | d81e659e2a8e6ce6ccae2e77ded063d86277c796 (patch) | |
tree | 7d70163ee4c9d78e068b32372027484bf31dc717 | |
parent | 897d3ff2ef75e2cdebbf7bd8cc0ea4b1626becc8 (diff) | |
download | ivy-csharp-d81e659e2a8e6ce6ccae2e77ded063d86277c796.zip ivy-csharp-d81e659e2a8e6ce6ccae2e77ded063d86277c796.tar.gz ivy-csharp-d81e659e2a8e6ce6ccae2e77ded063d86277c796.tar.bz2 ivy-csharp-d81e659e2a8e6ce6ccae2e77ded063d86277c796.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)
-rw-r--r-- | CSharp/Ivy/IvyPPC/IvyWatcher.cs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyWatcher.cs b/CSharp/Ivy/IvyPPC/IvyWatcher.cs index d61bafd..47b2239 100644 --- a/CSharp/Ivy/IvyPPC/IvyWatcher.cs +++ b/CSharp/Ivy/IvyPPC/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
|