summaryrefslogtreecommitdiff
path: root/Ivy/IvyClient.cs
diff options
context:
space:
mode:
authorfcolin2009-10-08 13:11:25 +0000
committerfcolin2009-10-08 13:11:25 +0000
commitc463b2d4b6614e01e7bad171581362ef41c0c9b2 (patch)
tree5b70ba5ee4af8ded66f81967dda78eab5fb878f2 /Ivy/IvyClient.cs
parent3e0c593975420de3fd87013d99f9a8c3a8eecf8a (diff)
downloadivy-csharp-c463b2d4b6614e01e7bad171581362ef41c0c9b2.zip
ivy-csharp-c463b2d4b6614e01e7bad171581362ef41c0c9b2.tar.gz
ivy-csharp-c463b2d4b6614e01e7bad171581362ef41c0c9b2.tar.bz2
ivy-csharp-c463b2d4b6614e01e7bad171581362ef41c0c9b2.tar.xz
correction des bug connexion concurrente
correction sur le ready message attente des deux endRegexp
Diffstat (limited to 'Ivy/IvyClient.cs')
-rw-r--r--Ivy/IvyClient.cs23
1 files changed, 18 insertions, 5 deletions
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;