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/IvyClient.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Ivy/IvyClient.cs') 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; -- cgit v1.1