Package org.jboss.aerogear.io.netty.handler.codec.sockjs

Examples of org.jboss.aerogear.io.netty.handler.codec.sockjs.SockJsSessionContext


                    if (future.isSuccess()) {
                        ctx.pipeline().remove(SockJsHandler.class);
                        ctx.pipeline().remove(CorsInboundHandler.class);
                        ctx.pipeline().remove(CorsOutboundHandler.class);
                        ctx.pipeline().addLast(new RawWebSocketSendHandler());
                        service.onOpen(new SockJsSessionContext() {
                            @Override
                            public void send(String message) {
                                ctx.writeAndFlush(new TextWebSocketFrame(message));
                            }
                            @Override
View Full Code Here


    @Test
    public void reapActiveUserAgent() throws InterruptedException {
        final String uaid = UUIDUtil.newUAID();
        final SimplePushServer simplePushServer = simplePushServer();
        final SockJsSessionContext sessionContext = newSessionContext(true);
        doRegister(uaid, simplePushServer);
        addUserAgent(uaid, sessionContext);

        exceute(new UserAgentReaper(simplePushServer));
        verify(sessionContext, never()).close();
View Full Code Here

    @Test(expected = IllegalStateException.class)
    public void reapInactiveUserAgent() throws InterruptedException {
        final String uaid = UUIDUtil.newUAID();
        final SimplePushServer simplePushServer = simplePushServer();
        final SockJsSessionContext sessionContext = newSessionContext(false);
        doRegister(uaid, simplePushServer);
        addUserAgent(uaid, sessionContext);

        exceute(new UserAgentReaper(simplePushServer));
        verify(sessionContext).close();
View Full Code Here

        final Channel channel = mock(Channel.class);
        when(channel.isActive()).thenReturn(active);
        when(channel.isRegistered()).thenReturn(active);
        final ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
        when(ctx.channel()).thenReturn(channel);
        final SockJsSessionContext sessionContext = mock(SockJsSessionContext.class);
        when(sessionContext.getContext()).thenReturn(ctx);
        return sessionContext;
    }
View Full Code Here

        @Override
        public Void call() throws Exception {
            try {
                final Notification notification = simplePushServer.handleNotification(endpoint, payload.toString(UTF_8));
                final String uaid = notification.uaid();
                final SockJsSessionContext session = userAgents.get(uaid).context();
                if (logger.isDebugEnabled()) {
                    logger.debug("Sending notification for UAID [ " + notification.uaid() + "] " +
                            toJson(new NotificationMessageImpl(notification.ack())));
                }
                session.send(toJson(new NotificationMessageImpl(notification.ack())));
                userAgents.updateAccessedTime(uaid);
            } catch (final ChannelNotFoundException e) {
                logger.debug("Could not find channel for [" + endpoint + "]");
            } catch (final VersionException e) {
                logger.debug(e.getMessage());
View Full Code Here

    @Test
    public void onOpen() throws Exception {
        final SockJsService service = mock(SockJsService.class);
        final SockJsSession sockJSSession = new SockJsSession("123", service);
        final SockJsSessionContext session = mock(SockJsSessionContext.class);
        sockJSSession.onOpen(session);
        verify(service).onOpen(session);
        assertThat(sockJSSession.getState(), is(State.OPEN));
    }
View Full Code Here

    private EmbeddedChannel createWebsocketChannel(SimplePushServer simplePushServer) {
        return new EmbeddedChannel(new NotificationHandler(simplePushServer));
    }

    private SockJsSessionContext channelSession(final EmbeddedChannel ch) {
        return new SockJsSessionContext() {
            @Override
            public void send(final String message) {
                ch.writeOutbound(message);
            }
View Full Code Here

                    if (future.isSuccess()) {
                        ctx.pipeline().remove(SockJsHandler.class);
                        ctx.pipeline().remove(CorsInboundHandler.class);
                        ctx.pipeline().remove(CorsOutboundHandler.class);
                        ctx.pipeline().addLast(new RawWebSocketSendHandler());
                        service.onOpen(new SockJsSessionContext() {
                            @Override
                            public void send(String message) {
                                ctx.writeAndFlush(new TextWebSocketFrame(message));
                            }
                            @Override
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.io.netty.handler.codec.sockjs.SockJsSessionContext

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.