summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/Ivy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC/Ivy.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs102
1 files changed, 41 insertions, 61 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs
index 4fc603b..2f522fe 100644
--- a/CSharp/Ivy/IvyPPC/Ivy.cs
+++ b/CSharp/Ivy/IvyPPC/Ivy.cs
@@ -52,7 +52,33 @@ namespace IvyBus
public event ClientAddBindingHandler addBinding;
/// <summary>fires when a client receive a remove binding from another client</summary>
public event ClientRemoveBindingHandler removeBinding;
-
+
+
+ public bool Debug
+ {
+ get
+ {
+ return debug;
+ }
+ set
+ {
+ debug = value;
+ }
+
+ }
+
+ public CultureInfo Culture
+ {
+ get
+ {
+ return culture;
+ }
+ set
+ {
+ culture = value;
+ }
+
+ }
/// <summary>IvyClients accesses the list of the connected clients</summary>
public List<IvyClient> IvyClients
@@ -63,18 +89,6 @@ namespace IvyBus
}
}
- public bool Debug
- {
- get
- {
- return debug;
- }
- set
- {
- debug = value;
- }
-
- }
/// <summary>ClientNames accesses the name list of the connected clients</summary>
private string ClientNames
{
@@ -201,6 +215,7 @@ namespace IvyBus
internal string applicationUniqueId; /* identifier Application unique timestamp-ipaddress-port */
internal ushort applicationPriority = DEFAULT_PRIORITY;
internal string ready_message = null;
+ internal CultureInfo culture = new CultureInfo("en-us");
// for synchronous event
private Control syncControl = null;
@@ -419,34 +434,6 @@ namespace IvyBus
}
- /// <summary> Send a message to someone on the bus
- /// </summary>
- /// <remarks>
- /// Performs a pattern matching according to everyone's regexps, and sends
- /// the results to the relevant ivy agents.
- /// There is one thread for each client connected, we could also
- /// create another thread each time we send a message.
- /// </remarks>
- /// <param name='message'>A message which will be compared to the regular
- /// expressions of the different clients
- /// </param>
- /// <returns>the number of messages actually sent
- ///
- /// </returns>
- public int sendMsg(string message)
- {
- int count = 0;
- // an alternate implementation would one sender thread per client
- // instead of one for all the clients. It might be a performance issue
- lock ( clients )
- {
- foreach (IvyClient client in clients )
- {
- count += client.sendMsg(message);
- }
- }
- return count;
- }
/// <summary> Send a formated message to someone on the bus
/// </summary>
/// <remarks>
@@ -463,25 +450,18 @@ namespace IvyBus
/// </returns>
public int sendMsg(string format, params object[] args )
{
- return sendMsg( string.Format( format, args ) );
- }
- /// <summary> Send a formated message to someone on the bus
- /// </summary>
- /// <remarks>
- /// Performs a pattern matching according to everyone's regexps, and sends
- /// the results to the relevant ivy agents.
- /// There is one thread for each client connected, we could also
- /// create another thread each time we send a message.
- /// </remarks>
- /// <param name='format'>A string message format to build the message
- /// <param name='args'>args used in message format
- /// </param>
- /// <returns>the number of messages actually sent
- ///
- /// </returns>
- public int sendMsg(CultureInfo culture, string format, params object[] args )
- {
- return sendMsg( string.Format( culture, format, args ) );
+ string msg = string.Format( culture, format, args );
+ int count = 0;
+ // an alternate implementation would one sender thread per client
+ // instead of one for all the clients. It might be a performance issue
+ lock (clients)
+ {
+ foreach (IvyClient client in clients)
+ {
+ count += client.sendMsg(msg);
+ }
+ }
+ return count;
}
/// <summary> Subscribes to a regular expression.
@@ -750,7 +730,7 @@ namespace IvyBus
{
throw new IvyException("(callCallback) Not regexp matching id " + key);
}
- if ( syncControl != null )
+ if ( syncControl != null && syncControl.Created )
syncControl.Invoke(bind.callback, new object[] { client, arg });
else bind.callback(client, arg);
}