aboutsummaryrefslogtreecommitdiff
path: root/src/Ivy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-xsrc/Ivy.java34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index ad8a4e6..b23125a 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -40,9 +40,13 @@ public class Ivy implements Runnable, IvyApplicationListener {
* the domain for the UDP rendez vous
*/
public static final String DEFAULT_DOMAIN = "127.255.255.255:"+DEFAULT_PORT;
+ /**
+ * the library version
+ */
+ public static String libVersion ="1.0.8";
- private static boolean debug = (System.getProperty("IVY_DEBUG")!=null) ;
- private static int serial=0; /* an unique ID for each regexps */
+ private boolean debug;
+ private static int serial=0; /* an unique ID for each regexp */
private ServerSocket app;
private IvyWatcher watch;
private Thread server;
@@ -69,6 +73,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
public Ivy( String name, String message, IvyApplicationListener appcb) {
appName = name;
ready_message = message;
+ debug = (System.getProperty("IVY_DEBUG")!=null);
if ( appcb != null ) ivyApplicationListenerList.addElement( appcb );
}
@@ -88,7 +93,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
} catch (IOException e) {
throw new IvyException("can't open TCP service socket " + e );
}
- traceDebug("TCP service open on port "+applicationPort);
+ traceDebug("lib: "+libVersion+" protocol: "+PROCOCOLVERSION+" TCP service open on port "+applicationPort);
watch = new IvyWatcher(this);
ivyRunning = true;
server = new Thread(this);
@@ -98,19 +103,19 @@ public class Ivy implements Runnable, IvyApplicationListener {
/**
* disconnects from the Ivy bus.
- * TODO is there a bug here ? There is still a thread running and a
- * standalone application won't quit here.
+ *
+ * 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");
try {
+ app.close();
ivyRunning = false;
watch.stop();
- app.close();
- for ( int i = 0 ; i < clients.size(); i++ ) {
+ for (int i=0;i<clients.size();i++) {
IvyClient client = (IvyClient)clients.elementAt(i);
client.close("normal Ivy Stopping...");
- // advertise that this is a normal
- //close for debugging purposes
}
} catch (IOException e) {
traceDebug("IOexception Stop ");
@@ -228,6 +233,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
for ( int i = 0 ; i < ivyApplicationListenerList.size(); i++ ) {
((IvyApplicationListener)ivyApplicationListenerList.elementAt(i)).die(client, id);
}
+ this.stop();
}
/* invokes the direct message callbacks
@@ -254,13 +260,11 @@ public class Ivy implements Runnable, IvyApplicationListener {
clients.removeElement( client );
}
- void callCallback(IvyClient client, Integer key, String msgarg) throws IvyException {
+ void callCallback(IvyClient client, Integer key, String[] tab) throws IvyException {
IvyMessageListener callback=(IvyMessageListener)callbacks.get(key);
if (callback==null){
throw new IvyException("(callCallback) Not regexp matching id "+key.intValue());
}
- String[] tab= myTokenize(msgarg,IvyClient.EndArg);
- System.out.println("received " + tab.length + " args");
callback.receive( client, tab);
}
@@ -334,7 +338,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
traceDebug("Error IvyServer exception: " + e.getMessage());
System.out.println("DEBUG TCP socket reader caught an exception " + e.getMessage());
}
- }
+ } // while
traceDebug("IvyServer end of trans");
}
@@ -353,4 +357,6 @@ public class Ivy implements Runnable, IvyApplicationListener {
messages_classes = msg_classes;
}
-}
+} // class Ivy
+
+/* EOF */