summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
authorfcolin2009-10-08 13:11:25 +0000
committerfcolin2009-10-08 13:11:25 +0000
commitc463b2d4b6614e01e7bad171581362ef41c0c9b2 (patch)
tree5b70ba5ee4af8ded66f81967dda78eab5fb878f2 /Ivy
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')
-rw-r--r--Ivy/IvyApplicationBinding.cs2
-rw-r--r--Ivy/IvyClient.cs23
-rw-r--r--Ivy/IvyEventArgs.cs6
3 files changed, 22 insertions, 9 deletions
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<string>();
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
/// <summary>
/// Args of Ivy generated events
/// </summary>
- 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
/// <summary>
/// Arg of the Die Event
/// </summary>
- 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
/// <summary>
/// Arg for the Normal Ivy Message received
/// </summary>
- public IvyMessageEventArgs(IvyClient app, int id, string[] args)
+ internal IvyMessageEventArgs(IvyClient app, int id, string[] args)
: base( app, id, null)
{
this.arg_list = args;