aboutsummaryrefslogtreecommitdiff
path: root/src/Ivy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-xsrc/Ivy.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index b23125a..06d27bf 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -78,7 +78,12 @@ public class Ivy implements Runnable, IvyApplicationListener {
}
/**
- * connects the Ivy bus to a domain or list of domains
+ * connects the Ivy bus to a domain or list of domains.
+ *
+ * <li>One thread (IvyWatcher) to watch rendezvous traffic (UDP or TCPMulticast)
+ * <li>One thread (server/Ivy) to accept incoming connexions on server socket
+ * <li>a thread for each IvyClient when the connexion has been done
+ *
* @param domainbus 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
@@ -103,12 +108,9 @@ public class Ivy implements Runnable, IvyApplicationListener {
/**
* disconnects from the Ivy bus.
- *
- * TODO: it's buggy, the watcher is still there, the ivyclients are waiting
- * for one last message . Everything needs to be redesigned from scratch
*/
public void stop() {
- traceDebug("I want to leave");
+ if (!ivyRunning) { return; }
try {
app.close();
ivyRunning = false;
@@ -134,7 +136,8 @@ public class Ivy implements Runnable, IvyApplicationListener {
*/
public int sendMsg( String message ) {
int count = 0;
- // TODO: il faudrait mettre une Thread emission par client */
+ // TODO ? an alternate implementation is one sender thread per client
+ // instead of one for all the clients. It might be a performance issue
for ( int i = 0 ; i < clients.size(); i++ ) {
IvyClient client = (IvyClient)clients.elementAt(i);
count += client.sendMsg( message );
@@ -233,7 +236,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
for ( int i = 0 ; i < ivyApplicationListenerList.size(); i++ ) {
((IvyApplicationListener)ivyApplicationListenerList.elementAt(i)).die(client, id);
}
- this.stop();
+ stop();
}
/* invokes the direct message callbacks
@@ -296,9 +299,8 @@ public class Ivy implements Runnable, IvyApplicationListener {
}
- /*
+ /**
* checks the "validity" of a regular expression.
- * TODO i'm not sure this is still used by anything.
*/
boolean CheckRegexp( String exp ) {
boolean regexp_ok = true;
@@ -313,7 +315,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
/*
* TODO prevents two clients from connecting to each other at the same time
- * there is still a lingering bug here, that we could avoid with the
+ * there might still be a lingering bug here, that we could avoid with the
* SchizoToken.
*/
boolean checkConnected( IvyClient clnt ) {
@@ -329,17 +331,18 @@ public class Ivy implements Runnable, IvyApplicationListener {
* the service socket thread reader.
*/
public void run() {
+ // traceDebug("IvyServer beginning transmission");
while(ivyRunning){
try {
Socket socket = app.accept();
addClient(socket,true); // the peer called me
} catch( IOException e ) {
- /* TODO is it a normal termination on socket close ? */
traceDebug("Error IvyServer exception: " + e.getMessage());
System.out.println("DEBUG TCP socket reader caught an exception " + e.getMessage());
+ e.printStackTrace();
}
- } // while
- traceDebug("IvyServer end of trans");
+ }
+ // traceDebug("IvyServer end of transmission");
}