From a5ca9fd3f54783b7f9371d69574660f29fe0d10f Mon Sep 17 00:00:00 2001 From: jestin Date: Fri, 11 Aug 2000 09:15:47 +0000 Subject: Probe is the java implementation of ivyprobe(1). It supports the same syntax. --- src/Probe.java | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Probe.java (limited to 'src/Probe.java') diff --git a/src/Probe.java b/src/Probe.java new file mode 100644 index 0000000..6218e03 --- /dev/null +++ b/src/Probe.java @@ -0,0 +1,77 @@ +package fr.dgac.ivy ; +import gnu.getopt.Getopt; +import java.io.*; + +/** + * terminal implementation in java of the ivyprobe. + * For a graphical version, see TestIvySwing + * @see fr.dgac.ivy.TestIvySwing + * @author Yannick Jestin + * @author http://www.tls.cena.fr/products/ivy/ + */ +class Probe implements IvyApplicationListener, IvyMessageListener { + + public static void main(String[] args) { + Probe p = new Probe(); + Getopt opt = new Getopt("Probe",args,"b:d"); + int c; + String domain=Ivy.DEFAULT_DOMAIN; + while ((c = opt.getopt()) != -1) switch (c) { + case 'b': + domain=opt.getOptarg(); + break; + case 'd': + System.setProperty("IVY_DEBUG","yes"); + break; + default: + } + // connexion to the Bus + Ivy bus; + try { + bus=new Ivy("JPROBE","JPROBE ready",p); + for (int i=opt.getOptind();i Sent to " +bus.sendMsg(s)+" peers"); + } catch (IvyException ie) { + System.out.println("Caught an exception. quitting. "+ie.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void connect(IvyClient client) { + System.out.println(client.getApplicationName() + " connected " ); + for (java.util.Enumeration e=client.getRegexps();e.hasMoreElements();) + System.out.println(client.getApplicationName() + " subscribes to " + +e.nextElement() ); + } + + public void disconnect(IvyClient client) { + System.out.println(client.getApplicationName() + " disconnected " ); + } + + public void die(IvyClient client, int id) { + System.out.println(client.getApplicationName() + " die "+ id ); + } + + public void directMessage(IvyClient client, int id, String arg) { + System.out.println(client.getApplicationName() + " direct Message "+ id + arg ); + } + + public void receive(IvyClient client, String[] args) { + String s=client.getApplicationName() + " sent"; + for (int i=0;i