Package org.apache.cometd.bayeux

Examples of org.apache.cometd.bayeux.Message


    public void publish(Message[] msgs) {
        if (msgs==null) return;
        MessageImpl[] imsgs = new MessageImpl[msgs.length];
        for (int i=0; msgs!=null && i<msgs.length; i++) {
            Message data = msgs[i];

            if (!(data instanceof MessageImpl))
                throw new IllegalArgumentException("Invalid message class, you can only publish messages "+
                                                   "created through the Bayeux.newMessage() method");
            /*if (log.isDebugEnabled()) {
View Full Code Here


        System.out.println("Client removed.");
    }

    public void deliver(Message[] msgs) {
        for (int i = 0; msgs != null && i < msgs.length; i++) {
            Message msg = msgs[i];
            System.out.println("[stock ticker server client ]received message:" + msg);
        }
    }
View Full Code Here

                            stock.setValue(stock.getValue() + change);
                        } else {
                            stock.setValue(stock.getValue() - change);
                        }
                        Channel ch = b.getChannel("/stock/"+stock.getSymbol(), true);
                        Message m = b.newMessage(c);
                        m.put("stock", stock.toString());
                        m.put("symbol", stock.getSymbol());
                        m.put("price", stock.getValueAsString());
                        m.put("change", stock.getLastChangeAsString());
                        ch.publish(m);
                        System.out.println("Stock: "+stock.getSymbol()+" Price: "+stock.getValueAsString()+" Change: "+stock.getLastChangeAsString());
                    }
                    Thread.sleep(850);
                }
View Full Code Here

        System.out.println("Client removed.");
    }

    public void deliver(Message[] msgs) {
        for (int i=0; msgs!=null && i<msgs.length; i++) {
            Message msg = msgs[i];
            System.out.println("[echochatclient ]received message:" + msg);
            Message m = b.newMessage(c);
            m.putAll(msg);
            //echo the same message
            m.put("user", "echochatserver");
            if (m.containsKey("msg")) {
                //simple chat demo
                String chat = (String) m.get("msg");
                m.put("msg", "echochatserver|I received your message-" + chat.substring(chat.indexOf("|") + 1));
            }
            System.out.println("[echochatclient ]sending message:" + m);
            msg.getChannel().publish(m);
        }
    }
View Full Code Here

                    sleep(5000);
                    Channel ch = b.getChannel("/chat/demo",false);
                    if (ch.getSubscribers().size()<=1) {
                        continue;
                    }
                    Message m = b.newMessage(c);
                    m.put("user","echochatserver");
                    m.put("chat","Time is:"+new java.sql.Date(System.currentTimeMillis()).toLocaleString());
                    m.put("join",false);
                    ch.publish(m);
                }catch (InterruptedException ignore) {
                    Thread.currentThread().interrupted();
                }catch (Exception x) {
                    x.printStackTrace();
View Full Code Here

    public void publish(Message[] msgs) {
        if (msgs==null) return;
        MessageImpl[] imsgs = new MessageImpl[msgs.length];
        for (int i=0; msgs!=null && i<msgs.length; i++) {
            Message data = msgs[i];

            if (!(data instanceof MessageImpl))
                throw new IllegalArgumentException("Invalid message class, you can only publish messages "+
                                                   "created through the Bayeux.newMessage() method");
            /*if (log.isDebugEnabled()) {
View Full Code Here

    public void publish(Message[] msgs) {
        if (msgs==null) return;
        MessageImpl[] imsgs = new MessageImpl[msgs.length];
        for (int i=0; msgs!=null && i<msgs.length; i++) {
            Message data = msgs[i];

            if (!(data instanceof MessageImpl))
                throw new IllegalArgumentException("Invalid message class, you can only publish messages "+
                                                   "created through the Bayeux.newMessage() method");
            if (log.isDebugEnabled()) {
View Full Code Here

        System.out.println("Client removed.");
    }

    public void deliver(Message[] msgs) {
        for (int i=0; msgs!=null && i<msgs.length; i++) {
            Message msg = msgs[i];
            System.out.println("[echochatclient ]received message:" + msg);
            Message m = b.newMessage(c);
            m.putAll(msg);
            //echo the same message
            m.put("user", "echochatserver");
            if (m.containsKey("msg")) {
                //simple chat demo
                String chat = (String) m.get("msg");
                m.put("msg", "echochatserver|I received your message-" + chat.substring(chat.indexOf("|") + 1));
            }
            System.out.println("[echochatclient ]sending message:" + m);
            msg.getChannel().publish(m);
        }
    }
View Full Code Here

                    sleep(5000);
                    Channel ch = b.getChannel("/chat/demo",false);
                    if (ch.getSubscribers().size()<=1) {
                        continue;
                    }
                    Message m = b.newMessage(c);
                    m.put("user","echochatserver");
                    m.put("chat","Time is:"+new java.sql.Date(System.currentTimeMillis()).toLocaleString());
                    m.put("join",false);
                    ch.publish(m);
                }catch (InterruptedException ignore) {
                    Thread.currentThread().interrupted();
                }catch (Exception x) {
                    x.printStackTrace();
View Full Code Here

        System.out.println("Client removed.");
    }

    public void deliver(Message[] msgs) {
        for (int i = 0; msgs != null && i < msgs.length; i++) {
            Message msg = msgs[i];
            System.out.println("[stock ticker server client ]received message:" + msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cometd.bayeux.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.