Package org.cometd

Examples of org.cometd.Channel


    }

    private void broadcastMembers(Set<String> members)
    {
        // Broadcast the new members list
        Channel channel = getBayeux().getChannel("/chat/members", false);
        if (channel != null)
            channel.publish(getClient(), members, null);
    }
View Full Code Here


            //TODO MULE-4320
            logger.warn("Servlet container has not yet initialised, ignoring event: " + event.getMessage().getPayload());
            return;
        }

        Channel chan = bayeux.getChannel(channel);
        if(chan!=null)
        {
            if (chan.getSubscribers().size() > 0 && cacheMessages && !messageCache.isEmpty())
            {
                while (!messageCache.isEmpty())
                {
                    for (Client client : chan.getSubscribers())
                    {
                        deliver(client, channel, messageCache.remove());
                    }
                    //deliver(getClient(), channel, messageCache.remove());
                }
            }

            Object data = event.getMessage().getPayload();
            //deliver(getClient(), channel, data);
            for (Client client : chan.getSubscribers())
            {
                deliver(client, channel, data);
            }
        }
        else if (cacheMessages)
View Full Code Here

    @Override
    public void processReplyTo(MuleEvent event, MuleMessage returnMessage, Object replyTo) throws MuleException
    {
        AbstractBayeux bayeux = ((BayeuxAware)connector).getBayeux();
        Channel channel = bayeux.getChannel(replyTo.toString(), false);
        if(channel==null)
        {
            logger.warn("No ajax Channel: " + replyTo + ". Maybe the client unregistered interest.");
            return;
        }
       
        Object ret;
        if(returnMessage.getExceptionPayload()!=null)
        {
            //If we are using RPC make sure we still send something back to the client so that the subscription is cancelled
            ret = returnMessage.getExceptionPayload().getMessage();
        }
        else
        {
            returnMessage.applyTransformers(event, getTransformers());
            ret = returnMessage.getPayload();
        }
        //Publish to interested clients
        for (Client client : channel.getSubscribers())
        {
            channel.publish(client, ret, null);
        }
    }
View Full Code Here

                    {
                        if (!_oort.isOort(joiner))
                            _seti.disassociate(userName);
                        if (timeout)
                        {
                            Channel channel=getBayeux().getChannel(channelName,false);
                            if (channel!=null)
                            {
                                Map<String,Object> leave = new HashMap<String,Object>();
                                leave.put("leave",Boolean.TRUE);
                                leave.put("user",userName);
                                channel.publish(null,leave,null);
                            }
                        }
                    }
                   
                });
View Full Code Here

    }

    /* ------------------------------------------------------------ */
    public Channel removeChannel(String channelId)
    {
        Channel channel = getChannel(channelId);

        boolean removed = false;
        if (channel!=null)
            removed = channel.remove();

        if (removed)
            return channel;
        else
            return null;
View Full Code Here

                public void removed(String clientId, boolean timeout)
                {
                    members.values().remove(clientId);
                    Log.info("members: " + members);
                    // Broadcast the members to all existing members
                    Channel channel = getBayeux().getChannel(channelName, false);
                    if (channel != null) channel.publish(getClient(), members.keySet(), messageId);
                }
            });

            Log.info("Members: " + members);
            // Broadcast the members to all existing members
View Full Code Here

    }

    /* ------------------------------------------------------------ */
    public Channel removeChannel(String channelId)
    {
        Channel channel = getChannel(channelId);
       
        boolean removed = false;
        if (channel!=null)
            removed = channel.remove();
       
        if (removed)
            return channel;
        else
            return null;
View Full Code Here

        for ( String[] test : tests )
        {
            _bayeux.getChannel(test[0], true);
            assertEquals(test[1], _bayeux.getChannels().toString());
           
            Channel removed = _bayeux.removeChannel(test[2]);
            assertEquals(test[3], removed == null? null : removed.toString());
            assertEquals(test[4], _bayeux.getChannels().toString());
        }
    }
View Full Code Here

        if (params<2 || params>4)
            throw new IllegalArgumentException("Method '"+methodName+"' does not have 2or3 parameters");
        if (!Client.class.isAssignableFrom(method.getParameterTypes()[0]))
            throw new IllegalArgumentException("Method '"+methodName+"' does not have Client as first parameter");

        Channel channel=_bayeux.getChannel(channelId,true);

        if (((ChannelImpl)channel).getChannelId().isWild())
        {
            final Method m=method;
            Client wild_client=_bayeux.newClient(_name+"-wild");
            wild_client.addListener(_listener instanceof MessageListener.Asynchronous?new AsyncWildListen(wild_client,m):new SyncWildListen(wild_client,m));
            channel.subscribe(wild_client);
        }
        else
        {
            _methods.put(channelId,method);
            channel.subscribe(_client);
        }
    }
View Full Code Here

                public void removed(String clientId, boolean timeout)
                {
                    members.values().remove(clientId);
                    Log.info("members: " + members);
                    // Broadcast the members to all existing members
                    Channel channel = getBayeux().getChannel(channelName, false);
                    if (channel != null) channel.publish(getClient(), members.keySet(), messageId);
                }
            });

            Log.info("Members: " + members);
            // Broadcast the members to all existing members
View Full Code Here

TOP

Related Classes of org.cometd.Channel

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.