When the communication with the server is finished, the {@link BayeuxClient} can bedisconnected from the Bayeux server.
Typical usage:
// Handshake String url = "http://localhost:8080/cometd"; BayeuxClient client = new BayeuxClient(url, LongPollingTransport.create(null)); client.handshake(); client.waitFor(1000, BayeuxClient.State.CONNECTED); // Subscription to channels ClientSessionChannel channel = client.getChannel("/foo"); channel.subscribe(new ClientSessionChannel.MessageListener() { public void onMessage(ClientSessionChannel channel, Message message) { // Handle the message } }); // Publishing to channels Map<String, Object> data = new HashMap<String, Object>(); data.put("bar", "baz"); channel.publish(data); // Disconnecting client.disconnect(); client.waitFor(1000, BayeuxClient.State.DISCONNECTED);
|
|