/* (non-Javadoc) * @see dojox.cometd.Client#publish(java.lang.String, java.lang.Object, java.lang.String) */ public void publish(String toChannel, Object data, String msgId) { Message msg = new MessageImpl(); msg.put(Bayeux.CHANNEL_FIELD, toChannel); msg.put(Bayeux.DATA_FIELD, data); if (msgId != null) msg.put(Bayeux.ID_FIELD, msgId); publish(msg); }
/* (non-Javadoc) * @see dojox.cometd.Client#deliver(dojox.cometd.Client, java.lang.String, java.lang.Object, java.lang.String) */ public void deliver(Client from, String toChannel, Object data, String id) { Message message = new MessageImpl(); message.put(Bayeux.CHANNEL_FIELD, toChannel); message.put(Bayeux.DATA_FIELD, data); if (id != null) message.put(Bayeux.ID_FIELD, id); synchronized (_inQ) { if (_mListeners == null) _inQ.add(message); else { for (MessageListener l : _mListeners) l.deliver(from, this, message); } } }
/* (non-Javadoc) * @see dojox.cometd.Client#remove(boolean) */ public void remove(boolean timeout) { Message msg = new MessageImpl(); msg.put(Bayeux.CHANNEL_FIELD, Bayeux.META_DISCONNECT); synchronized (_outQ) { _outQ.add(msg); _initialized = false; _disconnecting = true; if (_batch == 0 && _initialized && _push == null) _push = new Publish(); } }
protected void setMessages(List<Message> messages) { try { for (Message msg : messages) { msg.put(Bayeux.CLIENT_FIELD, _clientId); } String json = JSON.toString(messages); if (_formEncoded) setRequestContent(new ByteArrayBuffer("message=" + URLEncoder.encode(json, "utf-8"))); else setRequestContent(new ByteArrayBuffer(json, "utf-8")); } catch (Exception e) { Log.warn(e); } }
/* (non-Javadoc) * @see dojox.cometd.Client#unsubscribe(java.lang.String) */ public void unsubscribe(String toChannel) { Message msg = new MessageImpl(); msg.put(Bayeux.CHANNEL_FIELD, Bayeux.META_UNSUBSCRIBE); msg.put(Bayeux.SUBSCRIPTION_FIELD, toChannel); publish(msg); }