diff options
Diffstat (limited to 'CSharp')
-rw-r--r-- | CSharp/Ivy/IvyPPC/Ivy.cs | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index 1d1a3c1..0e6994a 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -63,15 +63,15 @@ namespace IvyBus [Category("Ivy")]
#endif
[DefaultValue(false)]
- public static bool VerboseDebug
+ public static bool DebugProtocol
{
get
{
- return debug;
+ return debugProtocol;
}
set
{
- debug = value;
+ debugProtocol = value;
}
}
@@ -263,7 +263,7 @@ namespace IvyBus /// the domain for the UDP rendez vous
private static readonly string DEFAULT_DOMAIN = "127.255.255.255:" + DEFAULT_PORT;
internal int protocolVersion = 3;
- private static bool debug; // false by default runtime
+ private static bool debugProtocol; // false by default runtime
private static ushort serial; /* an unique ID for each regexp */ // 0 by default runtime
private MyTcpListener app;
private List<IvyWatcher> watchers;
@@ -302,7 +302,7 @@ namespace IvyBus app_bindings = new List<IvyApplicationBinding>();
sent_messageFilter = new List<string>();
#if (!PocketPC)
- debug = Properties.Settings.Default.IvyDebug;
+ debugProtocol = Properties.Settings.Default.IvyDebug;
protocolVersion = Properties.Settings.Default.IvyProtocolVersion;
#endif
// get binding from Attribute IvyBinding
@@ -409,7 +409,7 @@ namespace IvyBus foreach (IvyBindingAttribute attr in Attribute.GetCustomAttributes(m, typeof(IvyBindingAttribute)))
{
//TODO check paramater type MessageHandler
- traceDebug("IvyBinding '" + attr.GetExpression(obj) + "' to Method " + m.Name);
+ Ivy.traceProtocol("Ivy", "BindAttibute " + attr.GetExpression(obj) + "' to Method " + m.Name);
EventHandler<IvyMessageEventArgs> handler;
#if (PocketPC)
handler = null; // TODO
@@ -466,7 +466,7 @@ namespace IvyBus {
throw new IvyException("can't open TCP service socket " + e);
}
- traceDebug("Ivy protocol: " + ProtocolVersion + " TCP service open on port " + applicationPort);
+ Ivy.traceProtocol("BindAttibute", "Ivy protocol: " + ProtocolVersion + " TCP service open on port " + applicationPort);
watchers = new List<IvyWatcher>();
Domain[] d = parseDomains(domainbus);
@@ -488,7 +488,7 @@ namespace IvyBus // Wait for readyness
while ( serverThread.ThreadState != System.Threading.ThreadState.Running || !app.IsActive())
{
- traceDebug( " Ivy Threading start in progress..." );
+ Ivy.traceError("BindAttibute", " Ivy Threading start in progress..." );
Thread.Sleep( 100 );
}
#endif
@@ -544,7 +544,7 @@ namespace IvyBus lock (app)
{
stopped = true;
- traceDebug("beginning stopping the bus");
+ Ivy.traceProtocol("Ivy", "beginning stopping the bus");
try
{
// stopping the serverThread
@@ -584,9 +584,9 @@ namespace IvyBus }
catch (IOException e)
{
- traceDebug("IOexception Stop " + e.Message);
+ Ivy.traceError("Ivy", "IOexception Stop " + e.Message);
}
- traceDebug("the bus should have stopped so far");
+ Ivy.traceProtocol("Ivy", "the bus should have stopped so far");
}
}
@@ -1055,7 +1055,7 @@ namespace IvyBus */
private void Run()
{
- traceDebug("Ivy service Thread started");
+ Ivy.traceProtocol("Ivy", "Ivy service Thread started");
bool running = true;
while (running)
{
@@ -1069,21 +1069,26 @@ namespace IvyBus }
catch (IOException e)
{
- traceDebug("Ivy server socket reader caught an exception: " + e.Message);
+ Ivy.traceError("Ivy","Ivy server socket reader caught an exception: " + e.Message);
}
catch (SocketException e)
{
- traceDebug("my server socket has been closed " + e.Message);
+ Ivy.traceError("Ivy","my server socket has been closed " + e.Message);
running = false;
}
}
- traceDebug("Ivy service Thread stopped");
+ Ivy.traceProtocol("Ivy", "Ivy service Thread stopped");
}
[Conditional("DEBUG")]
- private static void traceDebug(string s)
+ internal static void traceProtocol(string name, string message)
{
- Trace.Assert(!debug, "-->ivy<-- " + s);
+ if ( debugProtocol )
+ Console.WriteLine( "-->{0}<-- {1}", name, message);
+ }
+ internal static void traceError(string name, string message)
+ {
+ Console.WriteLine("-->{0}<-- {1}", name, message);
}
internal class Domain
@@ -1134,7 +1139,7 @@ namespace IvyBus }
catch (ArgumentException e)
{
- traceDebug("Bad broascat addr " + net + "error " + e.Message);
+ Ivy.traceError("Ivy","Bad broascat addr " + net + "error " + e.Message);
return null;
}
return net;
|