Package org.cometd

Examples of org.cometd.Message


     */
    protected void extendIn(Message message)
    {
        if (_extensions!=null)
        {
            Message m = message;
            String channelId = m.getChannel();
            if (channelId != null)
            {
                if (channelId.startsWith(Bayeux.META_SLASH))
                    for (int i=_extensions.length;m!=null && i-->0;)
                        m=_extensions[i].rcvMeta(this,m);
                else
                    for (int i=_extensions.length;m!=null && i-->0;)
                        m=_extensions[i].rcv(this,m);
            }

            if (message!=m)
            {
                message.clear();
                if (m!=null)
                    for (Map.Entry<String,Object> entry:m.entrySet())
                        message.put(entry.getKey(),entry.getValue());
            }
        }
    }
View Full Code Here


            message.put(ID_FIELD,msgId);
        message.put(DATA_FIELD,data);

        message.setLazy(lazy);

        final Message m=extendSendBayeux(from,message);

        if (m != null)
            _root.doDelivery(to,from,m);
        if (m instanceof MessageImpl)
            ((MessageImpl)m).decRef();
View Full Code Here

            }

            // reply to connect message
            String id=message.getId();

            Message reply=newMessage(message);

            reply.put(CHANNEL_FIELD,META_CONNECT);
            reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
            if (advice != null)
                reply.put(ADVICE_FIELD,advice);
            if (id != null)
                reply.put(ID_FIELD,id);

            if (polling)
                transport.setMetaConnectReply(reply);
            else
                sendMetaReply(client,reply,transport);
View Full Code Here

            if (isLogInfo())
                logInfo("Disconnect " + client.getId());

            client.remove(false);

            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,META_DISCONNECT);
            reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
            String id=message.getId();
            if (id != null)
                reply.put(ID_FIELD,id);

            Message pollReply=transport.getMetaConnectReply();
            if (pollReply != null)
            {
                transport.setMetaConnectReply(null);
                sendMetaReply(client,pollReply,transport);
            }
View Full Code Here

            if (client != null)
                throw new IllegalStateException();

            if (_securityPolicy != null && !_securityPolicy.canHandshake(message))
            {
                Message reply=newMessage(message);
                reply.put(CHANNEL_FIELD,META_HANDSHAKE);
                reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
                reply.put(ERROR_FIELD,"403::Handshake denied");

                sendMetaReply(client,reply,transport);
                return;
            }

            client=newRemoteClient();

            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,META_HANDSHAKE);
            reply.put(VERSION_FIELD,"1.0");
            reply.put(MIN_VERSION_FIELD,"0.9");

            if (client != null)
            {
                reply.put(SUPPORTED_CONNECTION_TYPES_FIELD,_transports);
                reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
                reply.put(CLIENT_FIELD,client.getId());
                if (_advice != null)
                    reply.put(ADVICE_FIELD,_advice);
            }
            else
            {
                reply.put(Bayeux.SUCCESSFUL_FIELD,Boolean.FALSE);
                if (_advice != null)
                    reply.put(ADVICE_FIELD,_advice);
            }

            if (isLogDebug())
                logDebug("handshake.handle: reply=" + reply);

            String id=message.getId();
            if (id != null)
                reply.put(ID_FIELD,id);

            sendMetaReply(client,reply,transport);
        }
View Full Code Here

        @Override
        public void handle(ClientImpl client, Transport transport, Message message) throws IOException
        {
            if (message == null)
            {
                Message reply = newMessage(message);
                reply.put(SUCCESSFUL_FIELD, Boolean.FALSE);
                reply.put(ERROR_FIELD, "404::Message deleted");
                sendMetaReply(client, reply, transport);
                return;
            }

            String channel_id=message.getChannel();
            if (isClientUnknown(client) && message.containsKey(CLIENT_FIELD))
            {
                unknownClient(transport,channel_id);
                return;
            }

            String id=message.getId();

            ChannelId cid=getChannelId(channel_id);
            Object data=message.get(Bayeux.DATA_FIELD);

            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,channel_id);
            if (id != null)
                reply.put(ID_FIELD,id);

            if (data == null)
            {
                message=null;
                reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
                reply.put(ERROR_FIELD,"403::No data");
            }
            else if (!_securityPolicy.canPublish(client,channel_id,message))
            {
                message=null;
                reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
                reply.put(ERROR_FIELD,"403::Publish denied");
            }
            else
            {
                reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
            }

            sendMetaReply(client,reply,transport);

            if (message != null)
View Full Code Here

            {
                cid=getChannelId(subscribe_id);
                can_subscribe=_securityPolicy.canSubscribe(client,subscribe_id,message);
            }

            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,META_SUBSCRIBE);
            reply.put(SUBSCRIPTION_FIELD,subscribe_id);

            if (can_subscribe)
            {
                if (cid != null)
                {
                    ChannelImpl channel=getChannel(cid);
                    if (channel == null && _securityPolicy.canCreate(client,subscribe_id,message))
                        channel=(ChannelImpl)getChannel(subscribe_id,true);

                    if (channel != null)
                    {
                        // Reduces the window of time where a server-side expiration
                        // or a concurrent disconnect causes the invalid client to be
                        // registered as subscriber and hence being kept alive by the
                        // fact that the channel references it.
                        if (isClientUnknown(client))
                        {
                            unknownClient(transport, META_SUBSCRIBE);
                            return;
                        }
                        else
                        {
                            channel.subscribe(client);
                        }
                    }
                    else
                    {
                        can_subscribe=false;
                    }
                }

                if (can_subscribe)
                {
                    reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
                }
                else
                {
                    reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
                    reply.put(ERROR_FIELD,"403::cannot create");
                }
            }
            else
            {
                reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
                reply.put(ERROR_FIELD,"403::cannot subscribe");

            }

            String id=message.getId();
            if (id != null)
                reply.put(ID_FIELD,id);

            sendMetaReply(client,reply,transport);
        }
View Full Code Here

            String channel_id=(String)message.get(SUBSCRIPTION_FIELD);
            ChannelImpl channel=getChannel(channel_id);
            if (channel != null)
                channel.unsubscribe(client);

            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,META_UNSUBSCRIBE);
            reply.put(SUBSCRIPTION_FIELD,channel_id);
            reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);

            String id=message.getId();
            if (id != null)
                reply.put(ID_FIELD,id);

            sendMetaReply(client,reply,transport);
        }
View Full Code Here

        }

        @Override
        public void handle(ClientImpl client, Transport transport, Message message) throws IOException
        {
            Message reply=newMessage(message);
            reply.put(CHANNEL_FIELD,META_PING);
            reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);

            String id=message.getId();
            if (id != null)
                reply.put(ID_FIELD,id);

            sendMetaReply(client,reply,transport);
        }
View Full Code Here

        message.put(Bayeux.CHANNEL_FIELD,getId());
        message.put(Bayeux.DATA_FIELD,data);
        if (id != null)
            message.put(Bayeux.ID_FIELD,id);

        Message m=_bayeux.extendSendBayeux(from,message);

        if (m != null)
        {
            for (Client t : to)
                deliverToSubscriber((ClientImpl)t,from,m);
View Full Code Here

TOP

Related Classes of org.cometd.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.