aboutsummaryrefslogtreecommitdiff
path: root/src/Probe.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Probe.java')
-rw-r--r--src/Probe.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Probe.java b/src/Probe.java
index e086560..be56d35 100644
--- a/src/Probe.java
+++ b/src/Probe.java
@@ -7,6 +7,10 @@
* (c) CENA
*
* Changelog:
+ * 1.2.7
+ * - added a .where function
+ * - added a .bound function
+ * - added a .dieall-yes-i-am-sure function
* 1.2.6
* - no more java ping
* 1.2.5
@@ -49,7 +53,7 @@ import org.apache.regexp.*;
public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBindListener, Runnable {
- public static final String helpCommands = "Available commands:\n.die CLIENTNAME sends a die message\n.direct CLIENTNAME ID MESSAGE sends the direct message to the client, with a message id set to the numerical ID\n.bye quits the application\n.quit idem\n.list lists the available clients\n.bind REGEXP binds to a regexp at runtime\n.unbind REGEXP unbinds to a regexp at runtime";
+ public static final String helpCommands = "Available commands:\n.die CLIENT\t\t\t* sends a die message\n.dieall-yes-i-am-sure\t\t* sends a die to all clients\n.direct CLIENT ID MSG\t\t* sends the direct message to the client\n.bye\t\t\t\t* quits the probe\n.quit\t\t\t\t* quites the probe\n.list\t\t\t\t* lists the clients on the bus\n.bind REGEXP\t\t\t* subscribes to a regexp\n.unbind REGEXP\t\t\t* unsubscribes to a regexp\n.bound CLIENT\t\t\t* lists the subscriptions of a client\n.bound\t\t\t\t* lists the probe's subscriptions\n.where CLIENT\t\t\t* displays the host where a client runs";
public static final String helpmsg = "usage: java fr.dgac.ivy.Probe [options] [regexp]\n\t-b BUS\tspecifies the Ivy bus domain\n\t-n ivyname (default JPROBE)\n\t-q\tquiet, no tty output\n\t-d\tdebug\n\t-t\ttime stamp each message\n\t-s\tsends to self\n\t-h\thelp\n\n\t regexp is a Perl5 compatible regular expression";
@@ -127,6 +131,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
traceDebug("Thread started");
Thread thisThread=Thread.currentThread();
String s;
+ println("probe ready, type .help and return to get help");
// "infinite" loop on keyboard input
while (looperThread==thisThread) {
try {
@@ -167,6 +172,9 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
println("-> not sent, the message contains incorrect characters");
}
return;
+ } else if (s.lastIndexOf(".dieall-yes-i-am-sure")>=0){
+ Vector v=bus.getIvyClients();
+ for (int i=0;i<v.size();i++) ((IvyClient)v.elementAt(i)).sendDie("java probe wants you to leave the bus");
} else if (s.lastIndexOf(".die ")>=0){
String target=s.substring(5);
Vector v=bus.getIvyClientsByName(target);
@@ -179,6 +187,22 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
} else {
println("you can't unsubscribe to " + regexp + ", your're not subscribed to it");
}
+ } else if (s.lastIndexOf(".bound ")>=0){
+ String target=s.substring(7);
+ Vector v=bus.getIvyClientsByName(target);
+ if (v.size()==0) println("no Ivy client with the name \""+target+"\"");
+ for (int i=0;i<v.size();i++) {
+ IvyClient ic=(IvyClient)v.elementAt(i);
+ println(target+" has subscribed to:");
+ for (Enumeration e = ic.getRegexps();e.hasMoreElements();) {
+ println("\t"+(String)e.nextElement());
+ }
+ }
+ } else if (s.lastIndexOf(".bound")>=0){
+ println("you have subscribed to:");
+ for (Enumeration e = bus.getSelfIvyClient().getRegexps();e.hasMoreElements();) {
+ println("\t"+(String)e.nextElement());
+ }
} else if (s.lastIndexOf(".bind ")>=0){
String regexp=s.substring(6);
try {
@@ -196,6 +220,13 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
for (int i=0;i<v.size();i++) {
println("-> "+((IvyClient)v.elementAt(i)).getApplicationName());
}
+ } else if ( s.lastIndexOf(".where ")>=0) {
+ String target=s.substring(7);
+ Vector v=bus.getIvyClientsByName(target);
+ if (v.size()==0) println("no Ivy client with the name \""+target+"\"");
+ for (int i=0;i<v.size();i++) {
+ println(target+" runs on "+((IvyClient)v.elementAt(i)).getHostName());
+ }
} else if ( s.lastIndexOf(".help")>=0) {
println(helpCommands);
} else if ( s.charAt(0)=='.') {