Package org.cometd.bayeux.server

Examples of org.cometd.bayeux.server.LocalSession


        assertTrue(processed);

        String parentChannel = new ChannelId(ListenerWithParametersService.CHANNEL).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
        message.setChannel(parentChannel + "/" + value);
        message.setData(new HashMap());
        bayeuxServer.handle((ServerSessionImpl)remote.getServerSession(), message);

        assertTrue(latch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here


        String parentChannel = new ChannelId(ListenerWithParametersNotBindingService.CHANNEL).getParent();
        String grandParentChannel = new ChannelId(parentChannel).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
        // Wrong channel (does not bind to the template), the message must not be delivered.
        message.setChannel(grandParentChannel + "/test");
        message.setData(new HashMap());
        bayeuxServer.handle((ServerSessionImpl)remote.getServerSession(), message);

        assertFalse(latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

        assertTrue(processed);

        String parentChannel = new ChannelId(SubscriberWithParametersService.CHANNEL).getParent();

        // Fake a publish
        LocalSession remote = bayeuxServer.newLocalSession("remote");
        remote.handshake();
        ServerMessage.Mutable message = bayeuxServer.newMessage();
        message.setChannel(parentChannel + "/" + value);
        message.setData(new HashMap());
        bayeuxServer.handle((ServerSessionImpl)remote.getServerSession(), message);

        assertTrue(latch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here

        String channelName = "/data";
        final String dataContent = "random";
        final long extraContent = 13;
        final CountDownLatch latch = new CountDownLatch(1);

        LocalSession service = bayeux.newLocalSession("custom_serialization");
        service.handshake();
        service.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
        {
            public void onMessage(ClientSessionChannel channel, Message message)
            {
                Data data = (Data)message.getData();
                Assert.assertEquals(dataContent, data.content);
View Full Code Here

        String channelName = "/data";
        final String content = "random";
        final CountDownLatch latch = new CountDownLatch(1);

        LocalSession service = bayeux.newLocalSession("custom_serialization");
        service.handshake();
        service.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
        {
            public void onMessage(ClientSessionChannel channel, Message message)
            {
                Data data = (Data)message.getData();
                Assert.assertEquals(content, data.content);
View Full Code Here

            public void sessionRemoved(ServerSession session, boolean timedout)
            {
            }
        });

        LocalSession session = bayeux.newLocalSession("test");
        session.handshake();

        String channelName = "/test";
        final CountDownLatch messageLatch = new CountDownLatch(1);
        session.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
            {
                messageLatch.countDown();
            }
        });

        session.getChannel(channelName).publish("test");

        Assert.assertFalse(messageLatch.await(1, TimeUnit.SECONDS));

        session.disconnect();
    }
View Full Code Here

        Object service = new RemoteCallWithResultService(callerData, calleeData);
        boolean processed = processor.process(service);
        assertTrue(processed);

        LocalSession remote = bayeuxServer.newLocalSession("remoteCall");
        remote.handshake();
        ClientSessionChannel channel = remote.getChannel(Channel.SERVICE + RemoteCallWithResultService.CHANNEL);
        final CountDownLatch latch = new CountDownLatch(1);
        channel.addListener(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
View Full Code Here

    {
        Object service = new RemoteCallWithParametersWithResultService();
        boolean processed = processor.process(service);
        assertTrue(processed);

        LocalSession remote = bayeuxServer.newLocalSession("remoteCall");
        remote.handshake();

        final String parameter = "param1";
        ClientSessionChannel channel = remote.getChannel(Channel.SERVICE + "/test/" + parameter);
        final CountDownLatch latch = new CountDownLatch(1);
        channel.addListener(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
View Full Code Here

    {
        Object service = new TwoRemoteCallsWithResultService();
        boolean processed = processor.process(service);
        assertTrue(processed);

        LocalSession remote1 = bayeuxServer.newLocalSession("remoteCall1");
        remote1.handshake();

        LocalSession remote2 = bayeuxServer.newLocalSession("remoteCall2");
        remote2.handshake();

        final CountDownLatch latch = new CountDownLatch(2);
        final List<Message> responses = new ArrayList<>();

        ClientSessionChannel channel1 = remote1.getChannel(Channel.SERVICE + TwoRemoteCallsWithResultService.CHANNEL);
        channel1.addListener(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
            {
                if (message.isPublishReply())
                    return;
                responses.add(message);
                latch.countDown();
            }
        });

        ClientSessionChannel channel2 = remote2.getChannel(Channel.SERVICE + TwoRemoteCallsWithResultService.CHANNEL);
        channel2.addListener(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
            {
View Full Code Here

        Object service = new RemoteCallWithFailureService();
        boolean processed = processor.process(service);
        assertTrue(processed);

        LocalSession remote = bayeuxServer.newLocalSession("remoteCall");
        remote.handshake();
        ClientSessionChannel channel = remote.getChannel(Channel.SERVICE + RemoteCallWithFailureService.CHANNEL);
        final CountDownLatch latch = new CountDownLatch(1);
        channel.addListener(new ClientSessionChannel.MessageListener()
        {
            @Override
            public void onMessage(ClientSessionChannel channel, Message message)
View Full Code Here

TOP

Related Classes of org.cometd.bayeux.server.LocalSession

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.