From 3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605 Mon Sep 17 00:00:00 2001
From: fcolin
Date: Fri, 10 Oct 2008 15:45:54 +0000
Subject: Ajout de commentaire sur les menbres public
---
Ivy/Ivy.cs | 121 +++++++++++++++++++++++++++++++++++++++-------------
Ivy/Ivy.csproj | 3 +-
Ivy/IvyClient.cs | 48 +++++++++++++++------
Ivy/IvyEventArgs.cs | 61 +++++++++++++++++---------
Ivy/IvyUDPStream.cs | 21 ++++-----
Ivy/IvyWatcher.cs | 20 +++++----
6 files changed, 194 insertions(+), 80 deletions(-)
(limited to 'Ivy')
diff --git a/Ivy/Ivy.cs b/Ivy/Ivy.cs
index bfef8ab..1946133 100644
--- a/Ivy/Ivy.cs
+++ b/Ivy/Ivy.cs
@@ -30,17 +30,46 @@ namespace IvyBus
public class Ivy
{
/* Event */
+ ///
+ /// raise when an new IvyClient is connected
+ ///
public event EventHandler ClientConnected;
+ ///
+ /// raise when an new IvyClient is disconnected
+ ///
public event EventHandler ClientDisconnected;
+ ///
+ /// raise when a direct message is received
+ ///
public event EventHandler DirectMessageReceived;
+ ///
+ /// raise when some IvyClient ask me to die
+ ///
public event EventHandler DieReceived;
+ ///
+ /// raise when an IvyClient register a binding
+ ///
public event EventHandler BindingAdd;
+ ///
+ /// raise when an IvyClient unregister a binding
+ ///
public event EventHandler BindingRemove;
+ ///
+ /// raise when an IvyClient binding is filteredout
+ ///
public event EventHandler BindingFilter;
+ ///
+ /// raise when an IvyClient changer a binding
+ ///
public event EventHandler BindingChange;
+ ///
+ /// raise when an error message is received
+ ///
public event EventHandler ErrorMessage;
-
+ ///
+ /// Flag for displaying internal debug message of the protocol intrinsics
+ ///
public static bool DebugProtocol
{
get
@@ -53,7 +82,10 @@ namespace IvyBus
}
}
-
+ ///
+ /// Language for the Ivy SendMsg formating default en-US
+ /// ie: send point on float value sent
+ ///
public CultureInfo Culture
{
get
@@ -92,7 +124,9 @@ namespace IvyBus
}
}
- /// AppId the Application Unique ID
+ ///
+ /// AppId the Application Unique ID
+ ///
public string AppId
{
@@ -103,7 +137,9 @@ namespace IvyBus
}
-
+ ///
+ /// the Ivy Protocol version
+ ///
public int ProtocolVersion
{
get
@@ -113,8 +149,9 @@ namespace IvyBus
}
- /// IsRunning is the bus Started and connected ?
-
+ ///
+ /// IsRunning is the bus Started and connected ?
+ ///
public bool IsRunning
{
get
@@ -167,6 +204,9 @@ namespace IvyBus
private Thread serverThread; // to ensure quick communication of the end
private AutoResetEvent tcplistener_running;
+ ///
+ /// the Ivy Assembly version
+ ///
static public Version Version
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
@@ -200,7 +240,8 @@ namespace IvyBus
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the Ivy Bus.
+ /// Readies the structures for the software bus connexion.
///
public Ivy()
{
@@ -351,7 +392,10 @@ namespace IvyBus
OnClientRemoveBinding(new IvyEventArgs(clnt, id, clientbind.binding.Expression));
}
- // Autobinding on static method
+ ///
+ /// Automatic binding on static method of a Type
+ ///
+ ///
public void BindAttribute(Type type)
{
if (type == null) return;
@@ -374,7 +418,12 @@ namespace IvyBus
}
}
}
- // Autobinding on instance method
+
+
+ ///
+ /// Autobinding on instance method
+ ///
+ ///
public void BindAttribute(object target)
{
if (target == null) return;
@@ -398,6 +447,10 @@ namespace IvyBus
}
// Autobinding on IvyBindingAttribute method
+ ///
+ /// Automatic binding of IvyBindAttribute in an assembly
+ ///
+ ///
public void BindAttribute(Assembly target)
{
if (target != null)
@@ -477,22 +530,7 @@ namespace IvyBus
clients.Sort();
}
}
- /* a small private method for debbugging purposes */
-
- public static string Domains(string toParse)
- {
- string domainbus = GetDomain(toParse);
- StringBuilder s = new StringBuilder("broadcasting on ");
- Ivy.Domain[] d = parseDomains(domainbus);
- for (int index = 0; index < d.Length; index++)
- {
- s.Append(d[index].Domainaddr);
- s.Append(":");
- s.Append(d[index].Port);
- s.Append(" ");
- }
- return s.ToString();
- }
+
internal static Domain[] parseDomains(string domainbus)
{
@@ -584,6 +622,7 @@ namespace IvyBus
{
this.Join(Timeout.Infinite);
}
+
///
/// Send a formated message to someone on the bus
///
@@ -673,7 +712,11 @@ namespace IvyBus
return count;
}
- //
+ ///
+ /// Make a binding to a message using regular expresssion
+ ///
+ ///
+ ///
public int BindMsg(IvyApplicationBinding newBinding)
{
newBinding.Key = Interlocked.Increment(ref serial);
@@ -729,7 +772,8 @@ namespace IvyBus
{
try
{
- c.stream.TokenDelBinding(id);
+ if ( c.stream != null )
+ c.stream.TokenDelBinding(id);
}
catch (IOException)
{
@@ -739,6 +783,12 @@ namespace IvyBus
}
lock (bindings) bindings.Remove(id);
}
+ ///
+ /// Change a binding already registred
+ ///
+ ///
+ ///
+ ///
public int ChangeMsg(int id, string expression)
{
IvyApplicationBinding newbind;
@@ -1048,7 +1098,10 @@ namespace IvyBus
}
-
+ ///
+ /// return the first non loopback adress
+ /// on a one network interface machine it will be my IP adresse
+ ///
public static IPAddress LocalIP
{
get
@@ -1065,7 +1118,11 @@ namespace IvyBus
return returnaddr;
}
}
-
+ ///
+ /// Get the FDQN Domain from a string
+ ///
+ ///
+ ///
public static string GetDomain(string domainBus)
{
#if (PocketPC) // TODO integrate in normal version
@@ -1264,7 +1321,11 @@ namespace IvyBus
}
}
-
+ ///
+ /// check Validity of Ivy Bus Domain
+ ///
+ ///
+ ///
public static bool ValidatingDomain(string domain)
{
// domain if of the form ip1[:port][,ip2[:port]] with ip of the form n1.n2.n3.n4
diff --git a/Ivy/Ivy.csproj b/Ivy/Ivy.csproj
index 5076a47..38af05b 100644
--- a/Ivy/Ivy.csproj
+++ b/Ivy/Ivy.csproj
@@ -1,7 +1,7 @@
Local
- 9.0.21022
+ 9.0.30729
2.0
{F2F03CF7-0087-4EDB-AD15-80C9E8DA2617}
SAK
@@ -171,6 +171,7 @@
+
SettingsSingleFileGenerator
diff --git a/Ivy/IvyClient.cs b/Ivy/IvyClient.cs
index 7f29e91..8421443 100644
--- a/Ivy/IvyClient.cs
+++ b/Ivy/IvyClient.cs
@@ -37,6 +37,9 @@ namespace IvyBus
return (other.clientPriority - clientPriority);
}
+ ///
+ /// the client application Name
+ ///
public String ApplicationName
{
get
@@ -68,6 +71,9 @@ namespace IvyBus
}
}
+ ///
+ /// adress of the client
+ ///
public IPAddress RemoteAddress
{
get
@@ -76,6 +82,9 @@ namespace IvyBus
}
}
+ ///
+ /// port of the client
+ ///
public int RemotePort
{
get
@@ -250,11 +259,19 @@ namespace IvyBus
{
}
catch (IOException ioe)
- {
- if (!(ioe.InnerException is SocketException))
- throw new IvyException(ioe.Message);
- if (((SocketException)ioe.InnerException).SocketErrorCode != SocketError.ConnectionReset)
+ {
+ SocketException se = ioe.InnerException as SocketException;
+ if (se != null)
+ {
+ if (!(se.SocketErrorCode == SocketError.ConnectionReset ||
+ se.SocketErrorCode == SocketError.ConnectionAborted))
+
+ throw new IvyException(ioe.Message);
+ }
+ else
+ {
throw new IvyException(ioe.Message);
+ }
}
// stop the thread and close the stream
@@ -558,9 +575,12 @@ namespace IvyBus
{
Ivy.traceProtocol(Resources.IvyClient, Resources.PingReceive + appName + " : " + arg);
}
-
-
-
+
+
+
+ ///
+ /// return full Application name pair
+ ///
public override String ToString()
{
return Resources.IvyClient+ " " + bus.appName + ":" + appName;
@@ -587,6 +607,9 @@ namespace IvyBus
}
Ivy.traceProtocol(Resources.IvyClient,Resources.PingerThreadStopped);
}
+ ///
+ /// stop the pinger Thread
+ ///
public virtual void StopPinging()
{
isPinging = false;
@@ -608,14 +631,15 @@ namespace IvyBus
if (disposing)
{
// Free other state (managed objects).
+ if (stream != null)
+ {
+ stream.Close();
+ stream = null;
+ }
}
// Free your own state (unmanaged objects).
// Set large fields to null.
- if (stream != null)
- {
- stream.Close();
- stream = null;
- }
+
}
// Use C# destructor syntax for finalization code.
diff --git a/Ivy/IvyEventArgs.cs b/Ivy/IvyEventArgs.cs
index a08f314..279f7c4 100644
--- a/Ivy/IvyEventArgs.cs
+++ b/Ivy/IvyEventArgs.cs
@@ -15,20 +15,32 @@ namespace IvyBus
private int id;
private string arg;
+ ///
+ /// the client who raise the event
+ ///
public IvyClient Client
{
get { return client; }
}
+ ///
+ /// the id argument of the message
+ ///
public int Id
{
get { return id; }
}
+ ///
+ /// the general purpose argument of the event
+ ///
public string Argument
{
get { return arg; }
}
+ ///
+ /// Args of Ivy generated events
+ ///
public IvyEventArgs(IvyClient app, int id, string arg)
{
this.client = app;
@@ -41,46 +53,57 @@ namespace IvyBus
/* return value for Die Event */
private bool forceExit;
+ ///
+ /// should we exit
+ ///
+ ///
+ /// by default the Ivy bus will make a call to Exit
+ /// set this flags to false if you wan't your application to survive
+ ///
+ /// true
public bool ForceExit
{
get { return forceExit; }
set { forceExit = value; }
}
+ ///
+ /// Arg of the Die Event
+ ///
public IvyDieEventArgs(IvyClient app, int id, string arg)
: base(app, id, arg)
{
forceExit = true;
}
}
- public class IvyMessageEventArgs : EventArgs
+ public class IvyMessageEventArgs : IvyEventArgs
{
- private IvyClient client;
- private int id;
- private string[] args;
-
- public IvyClient Client
- {
- get { return client; }
- }
-
- public int Id
- {
- get { return id; }
- }
+ private string[] arg_list;
+ ///
+ /// retreive all the arguments
+ ///
+ ///
public string[] GetArguments()
{
- return (string[])args.Clone();
+ return (string[])arg_list.Clone();
}
+
+ ///
+ /// retreive the argument at specified index
+ ///
+ ///
+ ///
public string this[int index]
{
- get { return args[index]; }
+ get { return arg_list[index]; }
}
+ ///
+ /// Arg for the Normal Ivy Message received
+ ///
public IvyMessageEventArgs(IvyClient app, int id, string[] args)
+ : base( app, id, null)
{
- this.client = app;
- this.id = id;
- this.args = args;
+ this.arg_list = args;
}
}
}
diff --git a/Ivy/IvyUDPStream.cs b/Ivy/IvyUDPStream.cs
index 986a550..0e64381 100644
--- a/Ivy/IvyUDPStream.cs
+++ b/Ivy/IvyUDPStream.cs
@@ -77,19 +77,20 @@ namespace IvyBus
if (disposing)
{
// Free other state (managed objects).
+ if (out_stream != null)
+ {
+ out_stream.Close();
+ out_stream = null;
+ }
+ if (in_stream != null)
+ {
+ in_stream.Close();
+ in_stream = null;
+ }
}
// Free your own state (unmanaged objects).
// Set large fields to null.
- if (out_stream != null)
- {
- out_stream.Close();
- out_stream = null;
- }
- if (in_stream != null)
- {
- in_stream.Close();
- in_stream = null;
- }
+
}
#endregion
}
diff --git a/Ivy/IvyWatcher.cs b/Ivy/IvyWatcher.cs
index b985ada..cc3fab1 100644
--- a/Ivy/IvyWatcher.cs
+++ b/Ivy/IvyWatcher.cs
@@ -81,9 +81,10 @@ namespace IvyBus
}
}
- /// the behaviour of each thread watching the UDP socket.
+ ///
+ /// the behaviour of each thread watching the UDP socket.
///
- public void Run()
+ private void Run()
{
Ivy.traceProtocol(Resources.IvyWatcher, "beginning of a watcher Thread");
@@ -172,7 +173,9 @@ namespace IvyBus
Ivy.traceProtocol(Resources.IvyWatcher, "ending stopping an IvyWatcher");
}
}
-
+ ///
+ /// send the boradcst message on all domains
+ ///
internal virtual void start()
{
lock (stream)
@@ -197,14 +200,15 @@ namespace IvyBus
if (disposing)
{
// Free other state (managed objects).
+ if (stream != null)
+ {
+ stream.Close();
+ stream = null;
+ }
}
// Free your own state (unmanaged objects).
// Set large fields to null.
- if (stream != null)
- {
- stream.Close();
- stream = null;
- }
+
}
#endregion
--
cgit v1.1