From 0ad76cbfd6a9bb8db4a0e0ea8137ea12cac3137f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:42:07 +0000 Subject: Utilisateur : Fcolin Date : 24/07/03 Heure : 16:07 Archivé dans $/EScribe/Ivy Commentaire: (vss 5) --- CSharp/Ivy/Ivy/Ivy.cs | 136 ++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 71 deletions(-) (limited to 'CSharp') diff --git a/CSharp/Ivy/Ivy/Ivy.cs b/CSharp/Ivy/Ivy/Ivy.cs index b56f251..47f427b 100644 --- a/CSharp/Ivy/Ivy/Ivy.cs +++ b/CSharp/Ivy/Ivy/Ivy.cs @@ -1,17 +1,8 @@ -/// a software bus package +/// François-Régis Colin +/// http://www.tls.cena.fr/products/ivy/ /// * -/// -/// François-Régis Colin -/// -/// http://www.tls.cena.fr/products/ivy/ +/// (C) CENA /// * -///
-/// Ivy bus = new Ivy("Dummy agent","ready");
-/// bus.bindMsg("(.*)",new IvyMessageHandler(myMessageListener));
-/// bus.start(null);
-/// 
-/// -///
namespace IvyBus { using System; @@ -22,6 +13,8 @@ namespace IvyBus using System.Threading; using System.Configuration; + /// The Main bus Class + /// public class Ivy { /* Event handler */ @@ -34,10 +27,20 @@ namespace IvyBus /* Event */ + /// fires when a new client connect to the bus + /// A callback handling the notification of connexions and + /// disconnections, may be null + /// + /// public event ClientConnectedHandler clientConnected; + /// fires when a client discconnect from the bus public event ClientDisconnectedHandler clientDisconnected; + /// fires when a client receive a direct message from another client public event DirectMessageHandler directMessageReceived; + /// fires when somebody ask for killing every client on the bus public event DieHandler dieReceived; + + /// IvyClients accesses the list of the connected clients public Hashtable IvyClients { get @@ -54,6 +57,7 @@ namespace IvyBus } } + /// ClientNames accesses the name list of the connected clients private String ClientNames { get @@ -70,6 +74,8 @@ namespace IvyBus } } + /// AppName the application name + public String AppName { get @@ -79,21 +85,14 @@ namespace IvyBus } - /// the name of the application on the bus - /// + /// the name of the application on the bus internal String appName; - /// the protocol version number - /// + /// the protocol version number internal const int PROCOCOLVERSION = 3; - /// the port for the UDP rendez vous, if none is supplied - /// + /// the port for the UDP rendez vous, if none is supplied internal const int DEFAULT_PORT = 2010; - /// the domain for the UDP rendez vous - /// + /// the domain for the UDP rendez vous internal static readonly String DEFAULT_DOMAIN = "127.255.255.255:" + DEFAULT_PORT; - /// the library version, useful for development purposes only, when java is - /// invoked with -DIVY_DEBUG - /// internal const String libVersion = "1.0.0"; private bool debug; @@ -110,18 +109,26 @@ namespace IvyBus internal String ready_message = null; /// Readies the structures for the software bus connexion. - /// * - /// All the dirty work is done un the start() method /// - /// - /// The name of your Ivy agent on the software bus - /// - /// The hellow message you will send once ready + /// This sample shows how to start working with Ivy. + /// + /// Ivy bus = new Ivy("Dummy agent","ready"); + /// bus.bindMsg("(.*)",new Ivy.MessageHandler(myMessageListener)); + /// bus.start(null); + /// + /// How to send & receive: + /// the Ivy agent A performs b.bindMsg("^Hello (*)",cb); + /// the Ivy agent B performs b2.sendMsg("Hello world"); + /// a thread in A will run the callback cb with its second argument set + /// to a array of String, with one single element, "world" + /// + /// + /// the real work begin in the start() method + /// + /// + /// The name of your Ivy agent on the software bus /// - /// A callback handling the notification of connexions and - /// disconnections, may be null - /// + /// The hellow message you will send once ready /// public Ivy(String name, String message) { @@ -136,13 +143,13 @@ namespace IvyBus } /// connects the Ivy bus to a domain or list of domains. - /// * - ///
  • One thread (IvyWatcher) for each traffic rendezvous (either UDP broadcast or TCPMulticast) - ///
  • One thread (serverThread/Ivy) to accept incoming connexions on server socket - ///
  • a thread for each IvyClient when the connexion has been done - /// * ///
  • - /// a domain of the form 10.0.0:1234, it is similar to the + /// + /// One thread (IvyWatcher) for each traffic rendezvous (either UDP broadcast or TCP Multicast). + /// One thread (serverThread/Ivy) to accept incoming connexions on server socket. + /// a thread for each IvyClient when the connexion has been done. + /// + /// a domain of the form 10.0.0:1234, it is similar to the /// netmask without the trailing .255. This will determine the meeting point /// of the different applications. Right now, this is done with an UDP /// broadcast. Beware of routing problems ! You can also use a comma @@ -253,12 +260,15 @@ namespace IvyBus } - /// 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. + ///

    Send a message to someone on the bus /// - /// A String which will be compared to the regular + /// + /// 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. + /// + /// A message which will be compared to the regular /// expressions of the different clients /// /// the number of messages actually sent @@ -280,20 +290,16 @@ namespace IvyBus } /// Subscribes to a regular expression. - /// * + /// + /// /// The callback will be executed with /// the saved parameters of the regexp as arguments when a message will sent - /// by another agent. A program doesn't receive its own messages. - ///

    Example: - ///
    the Ivy agent A performs

    b.bindMsg("^Hello (*)",cb);
    - ///
    the Ivy agent B performs
    b2.sendMsg("Hello world");
    - ///
    a thread in A will uun the callback cb with its second argument set - /// to a array of String, with one single element, "world" - ///
    - /// a perl regular expression, groups are done with parenthesis + /// by another agent. A program doesn't receive its own messages. + /// + /// + /// a regular expression, groups are done with parenthesis /// - /// any objects implementing the IvyMessageListener - /// interface, on the AWT/Swing framework + /// any objects implementing the Ivy.MessageListener /// /// the id of the regular expression /// @@ -316,9 +322,8 @@ namespace IvyBus } /// unsubscribes a regular expression - /// * /// - /// the id of the regular expression, returned when it was bound + /// the id of the regular expression, returned when it was bound /// /// public void unBindMsg(int id) @@ -337,12 +342,11 @@ namespace IvyBus } /// unsubscribes a regular expression - /// * /// /// a boolean, true if the regexp existed, false otherwise or /// whenever an exception occured during unbinding /// - /// the string for the regular expression + /// the string for the regular expression /// /// public bool unBindMsg(String re) @@ -399,15 +403,9 @@ namespace IvyBus } - - /// gives the names of IvyClient(s) - /// - /// gives a list of IvyClient(s) with the name given in parameter - /// * /// - /// The name of the Ivy agent you're looking for - /// + /// The name of the Ivy agent you're looking for /// public ArrayList getIvyClientsByName(String name) { @@ -495,8 +493,7 @@ namespace IvyBus } - /// checks the "validity" of a regular expression. - /// + /// checks the "validity" of a regular expression. internal bool CheckRegexp(String exp) { bool regexp_ok = true; @@ -630,7 +627,4 @@ namespace IvyBus } } } - // class Ivy - - /* EOF */ } \ No newline at end of file -- cgit v1.1