summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/IvyClient.cs
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:58:55 +0000
committerfcolin2007-02-01 09:58:55 +0000
commitcca6ec2ebc782a7c6fa9a48137d473face4d8599 (patch)
tree412a92248159d1e8b54f6dfab363502ddfb5bef3 /CSharp/Ivy/IvyPPC/IvyClient.cs
parent7f52c7a6d46c71c965c5c03abb18070d2fb663bd (diff)
downloadivy-csharp-cca6ec2ebc782a7c6fa9a48137d473face4d8599.zip
ivy-csharp-cca6ec2ebc782a7c6fa9a48137d473face4d8599.tar.gz
ivy-csharp-cca6ec2ebc782a7c6fa9a48137d473face4d8599.tar.bz2
ivy-csharp-cca6ec2ebc782a7c6fa9a48137d473face4d8599.tar.xz
Utilisateur : Fcolin Date : 23/06/06 Heure : 11:12 Archivé dans $/CSharp/Ivy/Ivy Commentaire: (vss 47)
Diffstat (limited to 'CSharp/Ivy/IvyPPC/IvyClient.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyClient.cs60
1 files changed, 33 insertions, 27 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyClient.cs b/CSharp/Ivy/IvyPPC/IvyClient.cs
index a207974..0e46765 100644
--- a/CSharp/Ivy/IvyPPC/IvyClient.cs
+++ b/CSharp/Ivy/IvyPPC/IvyClient.cs
@@ -46,8 +46,11 @@ namespace IvyBus
get
{
StringCollection tab = new StringCollection();
- foreach( IvyBindingBase bind in bindings.Values )
- tab.Add(bind.expression);
+ lock (bindings)
+ {
+ foreach (IvyBindingBase bind in bindings.Values)
+ tab.Add(bind.Expression);
+ }
return tab;
}
@@ -130,9 +133,9 @@ namespace IvyBus
// sends our regexps to the peer
lock( bus.bindings )
{
- foreach (Ivy.ApplicationBinding bind in bus.bindings.Values )
+ foreach (IvyApplicationBinding bind in bus.bindings.Values)
{
- stream.TokenAddBinding(bind);
+ stream.TokenAddBinding(bind.Binding, bind.Key, bind.Expression);
}
}
stream.TokenEndRegexp();
@@ -242,18 +245,15 @@ namespace IvyBus
internal int sendMsg(String message)
{
int count = 0;
-
+
lock( bindings )
{
- // hash message in V4 protocol only
- if (bus.ProtocolVersion == 4)
- IvyBindingSimple.Prepare(message);
- foreach (IvyBindingBase bind in bindings.Values )
+ foreach (IvyBindingBase bind in bindings.Values )
{
string[] args = bind.Match(message);
if ( stream != null && args!=null )
{
- stream.TokenMsg(bind.key, args);
+ stream.TokenMsg(bind.Key, args);
count++;
}
}
@@ -380,26 +380,32 @@ namespace IvyBus
close(false); // will fire diconnected
}
- void IvyProtocol.TokenAddBinding(Ivy.ApplicationBinding bind)
+ void IvyProtocol.TokenAddBinding(BindingType type, ushort id, string expression)
{
- try
- {
- if (bind.type == Ivy.BindingType.BindRegexp && !bus.CheckRegexp(bind.expression))
+
+ if (type == BindingType.Regexp && !bus.CheckRegexp(expression))
+ {
+ bus.OnClientFilterBinding(new IvyEventArgs(this, id, expression ));
+ return;
+ }
+ IvyBindingBase bind = null;
+ try
+ {
+ switch (type)
{
- bus.OnClientFilterBinding(new IvyEventArgs(this, bind.key, bind.expression ));
- return;
+ case BindingType.Regexp:
+ bind = new IvyBindingRegexp(id, expression);
+ break;
+ case BindingType.Simple:
+ bind = new IvyBindingSimple(id, expression);
+ break;
}
lock (bindings)
{
- 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);
+ bindings.Add(id, bind);
}
- bus.OnClientAddBinding(new IvyEventArgs(this, bind.key, bind.expression));
+ bus.OnClientAddBinding(new IvyEventArgs(this, id, expression));
}
catch (ArgumentException ex)
@@ -414,8 +420,8 @@ namespace IvyBus
{
try
{
- IvyBindingBase bind = (IvyBindingBase)bindings[id];
- bus.OnClientRemoveBinding(new IvyEventArgs(this, bind.key, bind.expression));
+ IvyBindingBase bind = bindings[id];
+ bus.OnClientRemoveBinding(new IvyEventArgs(this, bind.Key, bind.Expression));
bindings.Remove(id);
}
catch (KeyNotFoundException ex)
@@ -444,13 +450,13 @@ namespace IvyBus
}
void IvyProtocol.TokenEndRegexp()
{
- bus.OnClientConnected(new IvyEventArgs(this, 0, ""));
/*
* the peer is perhaps not ready to handle this message
* an assymetric processing should be written
*/
if (bus.ReadyMessage != null)
- sendMsg(bus.ReadyMessage);
+ sendMsg(bus.ReadyMessage);
+ bus.OnClientConnected(new IvyEventArgs(this, 0, ""));
}
void IvyProtocol.TokenStartRegexp(ushort id, string arg)
{