summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CSharp/Ivy/Ivy/IvyClient.cs42
1 files changed, 23 insertions, 19 deletions
diff --git a/CSharp/Ivy/Ivy/IvyClient.cs b/CSharp/Ivy/Ivy/IvyClient.cs
index 5a4a082..2664ef2 100644
--- a/CSharp/Ivy/Ivy/IvyClient.cs
+++ b/CSharp/Ivy/Ivy/IvyClient.cs
@@ -24,7 +24,7 @@ namespace IvyBus
/// die messages, direct messages, add or remove regexps, or quit. A thread is
/// created for each remote client.
/// </remarks>
- public class IvyClient : IvyProtocolInterface, IComparable<IvyClient>
+ public class IvyClient : IvyProtocol, IComparable<IvyClient>
{
public int CompareTo(IvyClient y)
{
@@ -85,7 +85,6 @@ namespace IvyBus
private string clientId; /* an unique ID for each IvyClient */
private int clientPriority; /* client priority */
- private bool peerCalling;
private volatile bool running = false;
private volatile Thread clientThread; // volatile to ensure the quick communication
private static bool doping = Properties.Settings.Default.IvyPing;
@@ -350,7 +349,7 @@ namespace IvyBus
}
- public void TokenDie(ushort id, string arg)
+ override internal void TokenDie(ushort id, string arg)
{
traceDebug("received die Message from " + appName);
// first, I'm not a first class IvyClient any more
@@ -368,9 +367,9 @@ namespace IvyBus
throw new IvyException(ioe.Message);
}
if ( !dontkillapp )
- Environment.Exit( -1 );
+ System.Windows.Forms.Application.Exit();
}
- public void TokenBye(ushort err, string arg)
+ override internal void TokenBye(ushort err, string arg)
{
// the peer quits
traceDebug("received bye Message from " + appName + "Raison: "+ arg);
@@ -387,24 +386,29 @@ namespace IvyBus
throw new IvyException(ioe.Message);
}
}
-
- internal void TokenAddBinding(IvyBindingBase bind)
+
+ override internal void TokenAddBinding(Ivy.ApplicationBinding bind)
{
try
{
lock( bindings )
{
- bindings.Add( id, bind);
+ IvyBindingBase binding;
+ if (bind.type == Ivy.BindingType.BindRegexp)
+ binding = new IvyBindingRegexp(bind.key, bind.expression);
+ else
+ binding = new IvyBindingSimple(bind.key, bind.expression);
+ bindings.Add( bind.key, binding);
}
bus.FireClientAddBinding( this, bind.expression );
}
catch (ArgumentException e)
{
- throw new IvyException("regexp error " + e.Message);
+ throw new IvyException("binding expression error " + e.Message);
}
}
- public void TokenDelBinding(ushort id)
+ override internal void TokenDelBinding(ushort id)
{
lock( bindings )
{
@@ -420,15 +424,15 @@ namespace IvyBus
}
}
}
- public void TokenMsg(ushort id, string[] arg)
+ override internal void TokenMsg(ushort id, string[] arg)
{
bus.FireCallback(this, id, arg);
}
- public void TokenError(ushort id, string arg)
+ override internal void TokenError(ushort id, string arg)
{
traceDebug("Error msg " + id + " " + arg);
}
- public void TokenApplicationId(ushort id, string arg)
+ override internal void TokenApplicationId(ushort id, string arg)
{
clientId = arg;
if ( clientPriority != id )
@@ -437,7 +441,7 @@ namespace IvyBus
bus.SortClients();
}
}
- public void TokenEndRegexp()
+ override internal void TokenEndRegexp()
{
bus.FireClientConnected(this);
/*
@@ -447,7 +451,7 @@ namespace IvyBus
if (bus.ready_message != null)
sendMsg(bus.ready_message);
}
- public void TokenStartRegexp(ushort id, string arg)
+ override internal void TokenStartRegexp(ushort id, string arg)
{
appName = arg;
appPort = id;
@@ -465,18 +469,18 @@ namespace IvyBus
}
}
- public void TokenDirectMsg(ushort id, string arg)
+ override internal void TokenDirectMsg(ushort id, string arg)
{
bus.FireDirectMessage(this, id, arg );
}
- public void TokenPing(string arg)
+ override internal void TokenPing(string arg)
{
// I receive a ping. I can answer a pong.
traceDebug("Ping msg from " + appName + " : " + arg );
stream.TokenPong(arg);
}
- public void TokenPong(string arg)
+ override internal void TokenPong(string arg)
{
traceDebug("Ping msg from " + appName + " : " + arg);
}
@@ -503,7 +507,7 @@ namespace IvyBus
{
try
{
- Thread.Sleep(new TimeSpan(10000 * PINGTIMEOUT));
+ Thread.Sleep(PINGTIMEOUT);
stream.TokenPing("are you here ?");
}
catch (ThreadInterruptedException ie)