From 1fa2f9f37991fe3234abf11d98bc9fd129d77a80 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:56:04 +0000 Subject: Utilisateur : Fcolin Date : 20/04/06 Heure : 13:15 Archivé dans $/CSharp/Ivy/Ivy Commentaire: filtrage classes (vss 64) --- CSharp/Ivy/IvyPPC/Ivy.cs | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'CSharp/Ivy') diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index 17a388e..e0573e4 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -44,6 +44,7 @@ namespace IvyBus public delegate ApplicationExit DieHandler(IvyClient app, int id, string arg); public delegate void ClientAddBindingHandler(IvyClient app, string arg); public delegate void ClientRemoveBindingHandler(IvyClient app, string arg); + public delegate void ClientFilterBindingHandler(IvyClient app, string arg); public delegate void ErrorMessageHandler(IvyClient app, int id, string arg); public delegate void MessageHandler(IvyClient app, string[] args); @@ -66,6 +67,8 @@ namespace IvyBus public event ClientAddBindingHandler BindingAdd; /// fires when a client receive a remove binding from another client public event ClientRemoveBindingHandler BindingRemove; + /// fires when a client receive a binding from another clientand it as been filtered + public event ClientRemoveBindingHandler BindingFilter; /// fires when a client receive a remove binding from another client public event ErrorMessageHandler ErrorMessage; @@ -281,8 +284,8 @@ 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; - private static ushort serial = 0; /* an unique ID for each regexp */ + private static bool debug; // false by deflaut runtime + private static ushort serial; /* an unique ID for each regexp */ // 0 by default runtime private MyTcpListener app; private List watchers; private volatile Thread serverThread; // to ensure quick communication of the end @@ -308,7 +311,7 @@ namespace IvyBus private string ready_message = null; private CultureInfo culture = new CultureInfo("en-us"); // for synchronous event - private Control syncControl = null; + private Control syncControl; // null by runtime default public Ivy() @@ -759,7 +762,7 @@ namespace IvyBus if (DirectMessageReceived != null) { if (IsSynchronous()) - syncControl.Invoke(DirectMessageReceived, new object[] { clnt, id, arg }); + syncControl.Invoke(DirectMessageReceived, clnt, id, arg ); else DirectMessageReceived(clnt, id, arg); } } @@ -768,7 +771,7 @@ namespace IvyBus if (ClientConnected != null) { if (IsSynchronous()) - syncControl.Invoke(ClientConnected, new object[] { clnt }); + syncControl.Invoke(ClientConnected, clnt ); else ClientConnected(clnt); } @@ -780,7 +783,7 @@ namespace IvyBus try { if (IsSynchronous()) - syncControl.Invoke(ClientDisconnected, new object[] { clnt }); + syncControl.Invoke(ClientDisconnected, clnt ); else ClientDisconnected(clnt); } catch (ObjectDisposedException ) @@ -794,7 +797,7 @@ namespace IvyBus if (BindingAdd != null) { if (IsSynchronous()) - syncControl.Invoke(BindingAdd, new object[] { clnt, regexp }); + syncControl.Invoke(BindingAdd, clnt, regexp ); else BindingAdd(clnt, regexp); } } @@ -803,16 +806,25 @@ namespace IvyBus if (BindingRemove != null) { if (IsSynchronous()) - syncControl.Invoke(BindingRemove, new object[] { clnt, regexp }); + syncControl.Invoke(BindingRemove, clnt, regexp ); else BindingRemove(clnt, regexp); } } + internal void FireClientFilterBinding(IvyClient clnt, string regexp) + { + if (BindingFilter != null) + { + if (IsSynchronous()) + syncControl.Invoke(BindingFilter, clnt, regexp); + else BindingFilter(clnt, regexp); + } + } internal ApplicationExit FireDie(IvyClient clnt, int id, string arg) { if (dieReceived != null) { if (IsSynchronous()) - return (ApplicationExit)syncControl.Invoke(dieReceived, new object[] { clnt, id, arg }); + return (ApplicationExit)syncControl.Invoke(dieReceived, clnt, id, arg ); else return dieReceived(clnt, id, arg); } return ApplicationExit.FORCE_EXIT; @@ -822,7 +834,7 @@ namespace IvyBus if (ErrorMessage != null) { if (IsSynchronous()) - syncControl.Invoke(ErrorMessage, new object[] { clnt, id, arg }); + syncControl.Invoke(ErrorMessage, clnt, id, arg ); else ErrorMessage(clnt, id, arg); } } @@ -880,7 +892,7 @@ namespace IvyBus throw new IvyException("(callCallback) Not regexp matching id " + key); } if (IsSynchronous()) - syncControl.Invoke(bind.callback, new object[] { client, arg }); + syncControl.Invoke(bind.callback, client, arg ); else bind.callback(client, arg); } -- cgit v1.1