diff options
author | jestin | 2002-03-06 12:56:11 +0000 |
---|---|---|
committer | jestin | 2002-03-06 12:56:11 +0000 |
commit | bdc113909fc711ce7c411d04a1f63c86d1b6c0d0 (patch) | |
tree | 5499833328e423b6a84736e1ffbdeb8ef4513945 /examples | |
parent | f6597057b9743aa727c407b7c483ba5d9bc240c0 (diff) | |
download | ivy-java-bdc113909fc711ce7c411d04a1f63c86d1b6c0d0.zip ivy-java-bdc113909fc711ce7c411d04a1f63c86d1b6c0d0.tar.gz ivy-java-bdc113909fc711ce7c411d04a1f63c86d1b6c0d0.tar.bz2 ivy-java-bdc113909fc711ce7c411d04a1f63c86d1b6c0d0.tar.xz |
An example from the documentation
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ivyTranslater.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/ivyTranslater.java b/examples/ivyTranslater.java new file mode 100644 index 0000000..f995270 --- /dev/null +++ b/examples/ivyTranslater.java @@ -0,0 +1,31 @@ +import fr.dgac.ivy.* ; + +class ivyTranslater implements IvyMessageListener { + + private Ivy bus; + + ivyTranslater() { + bus = new Ivy("IvyTranslater","Hello le monde",null); + bus.bindMsg("^Hello(.*)",this); + bus.bindMsg("^Bye$",new IvyMessageListener() { + // callback for "Bye" message + public void receive(IvyClient client, + String[] args) {System.exit(0);} + }); + try { + // starts the bus on the default domain or IVY_DOMAIN property + bus.start(null); + } catch (IvyException ie) { + System.err.println("can't run the Ivy bus" + ie.getMessage()); + } + } + + // callback associated to the "Hello" messages" + public void receive(IvyClient client, String[] args) { + bus.sendMsg("Bonjour"+((args.length>0)?args[0]:"")); + } + + public static void main(String args[]) { + new ivyTranslater(); + } +} |