Package org.mortbay.cometd

Examples of org.mortbay.cometd.MessageImpl


    /* (non-Javadoc)
     * @see dojox.cometd.Client#subscribe(java.lang.String)
     */
    public void subscribe(String toChannel)
    {
        Message msg=new MessageImpl();
        msg.put(Bayeux.CHANNEL_FIELD,Bayeux.META_SUBSCRIBE);
        msg.put(Bayeux.SUBSCRIPTION_FIELD,toChannel);
        publish(msg);
    }
View Full Code Here


    /* (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);
    }
View Full Code Here

    /* (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);

View Full Code Here

                    if (pollReply!=null)
                    {
                        // can we bypass response generation?
                        if (_refsThreshold>0 && size==1 && transport instanceof JSONTransport)
                        {
                            MessageImpl message = (MessageImpl)messages.peek();
                           
                            // is there a response already prepared
                            ByteBuffer buffer = message.getBuffer();
                            if (buffer!=null)
                            {
                                request.setAttribute("org.mortbay.jetty.ResponseBuffer",buffer);
                                ((MessageImpl)message).decRef();
                                flushed=true;
                            }
                            else if (message.getRefs()>=_refsThreshold)
                            {                               
                                byte[] contentBytes = ("[{\""+Bayeux.SUCCESSFUL_FIELD+"\":true,\""+
                                        Bayeux.CHANNEL_FIELD+"\":\""+Bayeux.META_CONNECT+"\"},"+
                                        message.getJSON()+"]").getBytes(StringUtil.__UTF8);
                                int contentLength = contentBytes.length;

                                String headerString = "HTTP/1.1 200 OK\r\n"+
                                "Content-Type: text/json; charset=utf-8\r\n" +
                                "Content-Length: " + contentLength + "\r\n" +
                                "\r\n";

                                byte[] headerBytes = headerString.getBytes(StringUtil.__UTF8);

                                buffer = ByteBuffer.allocateDirect(headerBytes.length+contentLength);
                                buffer.put(headerBytes);
                                buffer.put(contentBytes);
                                buffer.flip();

                                message.setBuffer(buffer);
                                request.setAttribute("org.mortbay.jetty.ResponseBuffer",buffer);
                                ((MessageImpl)message).decRef();
                                flushed=true;
                            }
                            else
View Full Code Here

    {
        @Override
        public MessageImpl newMessage()
        {
            //TODO no access to the message pool, need to have a fork of ContinuationBayeux to mimic exact behaviour
            MessageImpl message;//_messagePool.poll();
//            if (message == null)
//            {
                message=new MuleMessageImpl(this);
           // }
            message.incRef();
            return message;
        }
View Full Code Here

        @Override
        public MessageImpl newMessage(Message associated)
        {
            //TODO no access to the message pool, need to have a fork of ContinuationBayeux to mimic exact behaviour
            MessageImpl message;//_messagePool.poll();
//            if (message == null)
//            {
                message=new MuleMessageImpl(this);
            //}
            message.incRef();
            if (associated != null)
                message.setAssociated(associated);
            return message;
        }
View Full Code Here

TOP

Related Classes of org.mortbay.cometd.MessageImpl

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.