From c463b2d4b6614e01e7bad171581362ef41c0c9b2 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 8 Oct 2009 13:11:25 +0000 Subject: correction des bug connexion concurrente correction sur le ready message attente des deux endRegexp --- Ivy/IvyApplicationBinding.cs | 2 +- Ivy/IvyClient.cs | 23 ++++++++++++++++++----- Ivy/IvyEventArgs.cs | 6 +++--- 3 files changed, 22 insertions(+), 9 deletions(-) (limited to 'Ivy') diff --git a/Ivy/IvyApplicationBinding.cs b/Ivy/IvyApplicationBinding.cs index b5fe303..b8932c8 100644 --- a/Ivy/IvyApplicationBinding.cs +++ b/Ivy/IvyApplicationBinding.cs @@ -75,7 +75,7 @@ namespace IvyBus { } - public IvyApplicationBinding(BindingType type, string expression, params object[] args) + internal IvyApplicationBinding(BindingType type, string expression, params object[] args) { arguments = new Collection(); this.Binding = type; diff --git a/Ivy/IvyClient.cs b/Ivy/IvyClient.cs index d832dca..5671b6f 100644 --- a/Ivy/IvyClient.cs +++ b/Ivy/IvyClient.cs @@ -109,7 +109,8 @@ namespace IvyBus private int remotePort; private IPAddress remoteHost; - + private int readyToSend; + private Object readyToSendLock; // protected variables internal String appName; internal IvyProtocol stream; @@ -120,6 +121,8 @@ namespace IvyBus this.appName = appname; this.appPort = appPort; this.bus = bus; + readyToSendLock = new Object(); + this.readyToSend = 0; // set TCP_NODELAY to lower latency socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.NoDelay, true); @@ -165,6 +168,8 @@ namespace IvyBus } // send end of bindings peers can now send ReadyMessage stream.TokenEndRegexp(); + // try to send Ready Msg + SendReadyToPeer(); #if (!PocketPC) doping = Properties.Settings.Default.IvyPing; @@ -524,12 +529,20 @@ namespace IvyBus * the peer is perhaps not ready to handle this message * an assymetric processing should be written */ - if (bus.ReadyMessage != null) + SendReadyToPeer(); + } + + private void SendReadyToPeer() + { + lock (readyToSendLock) { - bus.SendMsgToClient(this, bus.ReadyMessage); + readyToSend++; + if (bus.ReadyMessage != null && readyToSend == 2) + { + bus.SendMsgToClient(this, bus.ReadyMessage); + } } - - } + } void IvyProtocol.TokenStartRegexp(int id, string arg) { //bool bindingToSend = appPort == 0; diff --git a/Ivy/IvyEventArgs.cs b/Ivy/IvyEventArgs.cs index 279f7c4..f9f6e73 100644 --- a/Ivy/IvyEventArgs.cs +++ b/Ivy/IvyEventArgs.cs @@ -41,7 +41,7 @@ namespace IvyBus /// /// Args of Ivy generated events /// - public IvyEventArgs(IvyClient app, int id, string arg) + internal IvyEventArgs(IvyClient app, int id, string arg) { this.client = app; this.id = id; @@ -69,7 +69,7 @@ namespace IvyBus /// /// Arg of the Die Event /// - public IvyDieEventArgs(IvyClient app, int id, string arg) + internal IvyDieEventArgs(IvyClient app, int id, string arg) : base(app, id, arg) { forceExit = true; @@ -100,7 +100,7 @@ namespace IvyBus /// /// Arg for the Normal Ivy Message received /// - public IvyMessageEventArgs(IvyClient app, int id, string[] args) + internal IvyMessageEventArgs(IvyClient app, int id, string[] args) : base( app, id, null) { this.arg_list = args; -- cgit v1.1