aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/Ivy.java2
-rwxr-xr-xsrc/IvyClient.java4
-rw-r--r--src/Probe.java13
3 files changed, 13 insertions, 6 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index 5b423eb..f7511ba 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -99,6 +99,8 @@ 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.
*/
public void stop() {
try {
diff --git a/src/IvyClient.java b/src/IvyClient.java
index dd0f156..e99574c 100755
--- a/src/IvyClient.java
+++ b/src/IvyClient.java
@@ -7,7 +7,7 @@ import java.util.*;
import gnu.regexp.*;
/**
- * A private Class for the the peers on the bus
+ * A private Class for the the peers on the bus.
*
* @author François-Régis Colin
* @author Yannick Jestin
@@ -19,7 +19,7 @@ import gnu.regexp.*;
* created for each remote client.
*/
-class IvyClient extends Thread {
+public class IvyClient extends Thread {
/* the protocol magic numbers */
final static int Bye = 0; /* end of the peer */
diff --git a/src/Probe.java b/src/Probe.java
index 6218e03..5152cda 100644
--- a/src/Probe.java
+++ b/src/Probe.java
@@ -8,6 +8,7 @@ import java.io.*;
* @see fr.dgac.ivy.TestIvySwing
* @author Yannick Jestin
* @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
+ * TODO BUG ! Should exit on end of user input
*/
class Probe implements IvyApplicationListener, IvyMessageListener {
@@ -39,12 +40,16 @@ class Probe implements IvyApplicationListener, IvyMessageListener {
DataInputStream in =
new DataInputStream(new BufferedInputStream(System.in));
// infinite loop on keyboard input
- while ((s=in.readLine()).length()!=0)
- System.out.println("-> Sent to " +bus.sendMsg(s)+" peers");
+ try {
+ while ((s=in.readLine()).length()!=0)
+ System.out.println("-> Sent to " +bus.sendMsg(s)+" peers");
+ } catch (NullPointerException e) {
+ bus.stop();
+ } catch (IOException e) {
+ bus.stop();
+ }
} catch (IvyException ie) {
System.out.println("Caught an exception. quitting. "+ie.getMessage());
- } catch (IOException e) {
- e.printStackTrace();
}
}