01: // $Id: UpHandlerTest.java,v 1.6 2005/05/30 16:15:12 belaban Exp $
02:
03: package org.jgroups.tests;
04:
05: import org.jgroups.*;
06: import org.jgroups.util.Util;
07:
08: /**
09: * Uses the pass-though facility of the Channel: events are passed (mostly) unfiltered from the channel
10: * to the application. The app quickly joins a groups, sends a message and then leaves again. The events
11: * received during this period are shown.
12: * @author Bela Ban
13: */
14: public class UpHandlerTest implements UpHandler {
15: Channel channel;
16:
17: public void start() throws Exception {
18: channel = new JChannel();
19: channel.setUpHandler(this );
20: channel.connect("UpHandlerTestGroup");
21:
22: channel.send(new Message(null, null, "Hello".getBytes()));
23: Util.sleep(2000);
24: channel.close();
25: }
26:
27: public void up(Event evt) {
28: System.out.println(evt);
29: }
30:
31: public static void main(String[] args) {
32: try {
33: new UpHandlerTest().start();
34: } catch (Exception e) {
35: System.err.println(e);
36: }
37: }
38: }
|