summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
authorfcolin2008-10-10 15:45:54 +0000
committerfcolin2008-10-10 15:45:54 +0000
commit3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605 (patch)
treeb4c691f61e44c2310887ccb77b94a519a73a7fdb /Ivy
parent8d10e8bbd1e19adc7c70e1101dbb69c213c910dd (diff)
downloadivy-csharp-3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605.zip
ivy-csharp-3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605.tar.gz
ivy-csharp-3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605.tar.bz2
ivy-csharp-3c9d0c18a19de1f1ec1c4e77f6b89fdf84d39605.tar.xz
Ajout de commentaire sur les menbres public
Diffstat (limited to 'Ivy')
-rw-r--r--Ivy/Ivy.cs121
-rw-r--r--Ivy/Ivy.csproj3
-rw-r--r--Ivy/IvyClient.cs48
-rw-r--r--Ivy/IvyEventArgs.cs61
-rw-r--r--Ivy/IvyUDPStream.cs21
-rw-r--r--Ivy/IvyWatcher.cs20
6 files changed, 194 insertions, 80 deletions
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 */
+ /// <summary>
+ /// raise when an new IvyClient is connected
+ /// </summary>
public event EventHandler<IvyEventArgs> ClientConnected;
+ /// <summary>
+ /// raise when an new IvyClient is disconnected
+ /// </summary>
public event EventHandler<IvyEventArgs> ClientDisconnected;
+ /// <summary>
+ /// raise when a direct message is received
+ /// </summary>
public event EventHandler<IvyEventArgs> DirectMessageReceived;
+ /// <summary>
+ /// raise when some IvyClient ask me to die
+ /// </summary>
public event EventHandler<IvyDieEventArgs> DieReceived;
+ /// <summary>
+ /// raise when an IvyClient register a binding
+ /// </summary>
public event EventHandler<IvyEventArgs> BindingAdd;
+ /// <summary>
+ /// raise when an IvyClient unregister a binding
+ /// </summary>
public event EventHandler<IvyEventArgs> BindingRemove;
+ /// <summary>
+ /// raise when an IvyClient binding is filteredout
+ /// </summary>
public event EventHandler<IvyEventArgs> BindingFilter;
+ /// <summary>
+ /// raise when an IvyClient changer a binding
+ /// </summary>
public event EventHandler<IvyEventArgs> BindingChange;
+ /// <summary>
+ /// raise when an error message is received
+ /// </summary>
public event EventHandler<IvyEventArgs> ErrorMessage;
-
+ /// <summary>
+ /// Flag for displaying internal debug message of the protocol intrinsics
+ /// </summary>
public static bool DebugProtocol
{
get
@@ -53,7 +82,10 @@ namespace IvyBus
}
}
-
+ /// <summary>
+ /// Language for the Ivy SendMsg formating default en-US
+ /// ie: send point on float value sent
+ /// </summary>
public CultureInfo Culture
{
get
@@ -92,7 +124,9 @@ namespace IvyBus
}
}
- /// <summary>AppId the Application Unique ID</summary>
+ /// <summary>
+ /// AppId the Application Unique ID
+ /// </summary>
public string AppId
{
@@ -103,7 +137,9 @@ namespace IvyBus
}
-
+ /// <summary>
+ /// the Ivy Protocol version
+ /// </summary>
public int ProtocolVersion
{
get
@@ -113,8 +149,9 @@ namespace IvyBus
}
- /// <summary>IsRunning is the bus Started and connected ?</summary>
-
+ /// <summary>
+ /// IsRunning is the bus Started and connected ?
+ /// </summary>
public bool IsRunning
{
get
@@ -167,6 +204,9 @@ namespace IvyBus
private Thread serverThread; // to ensure quick communication of the end
private AutoResetEvent tcplistener_running;
+ /// <summary>
+ /// the Ivy Assembly version
+ /// </summary>
static public Version Version
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
@@ -200,7 +240,8 @@ namespace IvyBus
/// <summary>
- /// Initializes a new instance of the <see cref="T:Ivy"/> class.
+ /// Initializes a new instance of the Ivy Bus.
+ /// Readies the structures for the software bus connexion.
/// </summary>
public Ivy()
{
@@ -351,7 +392,10 @@ namespace IvyBus
OnClientRemoveBinding(new IvyEventArgs(clnt, id, clientbind.binding.Expression));
}
- // Autobinding on static method
+ /// <summary>
+ /// Automatic binding on static method of a Type
+ /// </summary>
+ /// <param name="type"></param>
public void BindAttribute(Type type)
{
if (type == null) return;
@@ -374,7 +418,12 @@ namespace IvyBus
}
}
}
- // Autobinding on instance method
+
+
+ /// <summary>
+ /// Autobinding on instance method
+ /// </summary>
+ /// <param name="target"></param>
public void BindAttribute(object target)
{
if (target == null) return;
@@ -398,6 +447,10 @@ namespace IvyBus
}
// Autobinding on IvyBindingAttribute method
+ /// <summary>
+ /// Automatic binding of IvyBindAttribute in an assembly
+ /// </summary>
+ /// <param name="target"></param>
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);
}
+
/// <summary>
/// Send a formated message to someone on the bus
/// </summary>
@@ -673,7 +712,11 @@ namespace IvyBus
return count;
}
- //
+ /// <summary>
+ /// Make a binding to a message using regular expresssion
+ /// </summary>
+ /// <param name="newBinding"></param>
+ /// <returns></returns>
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);
}
+ /// <summary>
+ /// Change a binding already registred
+ /// </summary>
+ /// <param name="id"></param>
+ /// <param name="expression"></param>
+ /// <returns></returns>
public int ChangeMsg(int id, string expression)
{
IvyApplicationBinding newbind;
@@ -1048,7 +1098,10 @@ namespace IvyBus
}
-
+ /// <summary>
+ /// return the first non loopback adress
+ /// on a one network interface machine it will be my IP adresse
+ /// </summary>
public static IPAddress LocalIP
{
get
@@ -1065,7 +1118,11 @@ namespace IvyBus
return returnaddr;
}
}
-
+ /// <summary>
+ /// Get the FDQN Domain from a string
+ /// </summary>
+ /// <param name="domainBus"></param>
+ /// <returns></returns>
public static string GetDomain(string domainBus)
{
#if (PocketPC) // TODO integrate in normal version
@@ -1264,7 +1321,11 @@ namespace IvyBus
}
}
-
+ /// <summary>
+ /// check Validity of Ivy Bus Domain
+ /// </summary>
+ /// <param name="domain"></param>
+ /// <returns></returns>
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 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F2F03CF7-0087-4EDB-AD15-80C9E8DA2617}</ProjectGuid>
<SccProjectName>SAK</SccProjectName>
@@ -171,6 +171,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
+ <None Include="ClassDiagram1.cd" />
<None Include="Ivy.snippet" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
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);
}
+ /// <summary>
+ /// the client application Name
+ /// </summary>
public String ApplicationName
{
get
@@ -68,6 +71,9 @@ namespace IvyBus
}
}
+ /// <summary>
+ /// adress of the client
+ /// </summary>
public IPAddress RemoteAddress
{
get
@@ -76,6 +82,9 @@ namespace IvyBus
}
}
+ /// <summary>
+ /// port of the client
+ /// </summary>
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);
}
-
-
-
+
+
+
+ /// <summary>
+ /// return full Application name pair
+ /// </summary>
public override String ToString()
{
return Resources.IvyClient+ " " + bus.appName + ":" + appName;
@@ -587,6 +607,9 @@ namespace IvyBus
}
Ivy.traceProtocol(Resources.IvyClient,Resources.PingerThreadStopped);
}
+ /// <summary>
+ /// stop the pinger Thread
+ /// </summary>
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;
+ /// <summary>
+ /// the client who raise the event
+ /// </summary>
public IvyClient Client
{
get { return client; }
}
+ /// <summary>
+ /// the id argument of the message
+ /// </summary>
public int Id
{
get { return id; }
}
+ /// <summary>
+ /// the general purpose argument of the event
+ /// </summary>
public string Argument
{
get { return arg; }
}
+ /// <summary>
+ /// Args of Ivy generated events
+ /// </summary>
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;
+ /// <summary>
+ /// should we exit
+ /// </summary>
+ /// <remarks>
+ /// by default the Ivy bus will make a call to Exit
+ /// set this flags to false if you wan't your application to survive
+ /// </remarks>
+ /// <value>true</value>
public bool ForceExit
{
get { return forceExit; }
set { forceExit = value; }
}
+ /// <summary>
+ /// Arg of the Die Event
+ /// </summary>
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;
+ /// <summary>
+ /// retreive all the arguments
+ /// </summary>
+ /// <returns></returns>
public string[] GetArguments()
{
- return (string[])args.Clone();
+ return (string[])arg_list.Clone();
}
+
+ /// <summary>
+ /// retreive the argument at specified index
+ /// </summary>
+ /// <param name="index"></param>
+ /// <returns></returns>
public string this[int index]
{
- get { return args[index]; }
+ get { return arg_list[index]; }
}
+ /// <summary>
+ /// Arg for the Normal Ivy Message received
+ /// </summary>
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
}
}
- /// <summary> the behaviour of each thread watching the UDP socket.
+ /// <summary>
+ /// the behaviour of each thread watching the UDP socket.
/// </summary>
- 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");
}
}
-
+ /// <summary>
+ /// send the boradcst message on all domains
+ /// </summary>
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