congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
SockJsHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
SockJsHandler
in
org.jboss.aerogear.io.netty.handler.codec.sockjs.handler

Best Java code snippets using org.jboss.aerogear.io.netty.handler.codec.sockjs.handler.SockJsHandler (Showing top 12 results out of 315)

origin: aerogear/aerogear-simplepush-server

@Override
public void messageReceived(final ChannelHandlerContext ctx, final FullHttpRequest request) throws Exception {
  final String path = new QueryStringDecoder(request.getUri()).path();
  for (SockJsServiceFactory factory : factories.values()) {
    if (path.startsWith(factory.config().prefix())) {
      handleService(factory, request, ctx);
      return;
    }
  }
  writeNotFoundResponse(request, ctx);
}
origin: aerogear/aerogear-simplepush-server

private static void writeNotFoundResponse(final HttpRequest request, final ChannelHandlerContext ctx) {
  final FullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(), NOT_FOUND,
      Unpooled.copiedBuffer("Not found", CharsetUtil.UTF_8));
  writeResponse(ctx.channel(), request, response);
}
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

private static void handleService(final SockJsServiceFactory factory,
                 final FullHttpRequest request,
                 final ChannelHandlerContext ctx) throws Exception {
  if (logger.isDebugEnabled()) {
    logger.debug("RequestUri : [{}]", request.getUri());
  }
  final String pathWithoutPrefix = request.getUri().replaceFirst(factory.config().prefix(), "");
  final String path = new QueryStringDecoder(pathWithoutPrefix).path();
  if (Greeting.matches(path)) {
    writeResponse(ctx.channel(), request, Greeting.response(request));
  } else if (Info.matches(path)) {
    writeResponse(ctx.channel(), request, Info.response(factory.config(), request));
  } else if (Iframe.matches(path)) {
    writeResponse(ctx.channel(), request, Iframe.response(factory.config(), request));
  } else if (Transports.Type.WEBSOCKET.path().equals(path)) {
    addTransportHandler(new RawWebSocketTransport(factory.config(), factory.create()), ctx);
    ctx.fireChannelRead(request.retain());
  } else {
    final PathParams sessionPath = matches(path);
    if (sessionPath.matches()) {
      handleSession(factory, request, ctx, sessionPath);
    } else {
      writeNotFoundResponse(request, ctx);
    }
  }
}
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

switch (pathParams.transport()) {
case XHR:
  addTransportHandler(new XhrPollingTransport(factory.config(), request), ctx);
  addSessionHandler(new PollingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case JSONP:
  addTransportHandler(new JsonpPollingTransport(factory.config(), request), ctx);
  addSessionHandler(new PollingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case XHR_SEND:
  checkSessionExists(pathParams.sessionId(), request);
  addTransportHandler(new XhrSendTransport(factory.config()), ctx);
  addSessionHandler(new SendingSessionState(sessions, sessions.get(pathParams.sessionId())), ctx);
  break;
case XHR_STREAMING:
  addTransportHandler(new XhrStreamingTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case EVENTSOURCE:
  addTransportHandler(new EventSourceTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case HTMLFILE:
  addTransportHandler(new HtmlFileTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case JSONP_SEND:
  checkSessionExists(pathParams.sessionId(), request);
  addTransportHandler(new JsonpSendTransport(factory.config()), ctx);
origin: aerogear/aerogear-simplepush-server

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  if (cause instanceof SessionNotFoundException) {
    final SessionNotFoundException se = (SessionNotFoundException) cause;
    logger.debug("Could not find session [{}]", se.sessionId());
    writeNotFoundResponse(se.httpRequest(), ctx);
  } else {
    logger.error("exception caught:", cause);
    ctx.fireExceptionCaught(cause);
  }
}
origin: org.jboss.aerogear/aerogear-simplepush-server-netty

@Override
protected void initChannel(final SocketChannel socketChannel) throws Exception {
  final ChannelPipeline pipeline = socketChannel.pipeline();
  if (sockjsConfig.isTls()) {
    final SSLEngine engine = sslContext.createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast(new SslHandler(engine));
  }
  pipeline.addLast(new HttpServerCodec());
  pipeline.addLast(new HttpObjectAggregator(65536));
  final DefaultSimplePushServer simplePushServer = new DefaultSimplePushServer(datastore, simplePushConfig, privateKey);
  pipeline.addLast(new NotificationHandler(simplePushServer));
  pipeline.addLast(new CorsInboundHandler());
  pipeline.addLast(new SockJsHandler(new SimplePushServiceFactory(sockjsConfig, simplePushServer)));
  pipeline.addLast(backgroundGroup, new UserAgentReaperHandler(simplePushServer));
  pipeline.addLast(new CorsOutboundHandler());
}
origin: aerogear/aerogear-simplepush-server

private static void handleService(final SockJsServiceFactory factory,
                 final FullHttpRequest request,
                 final ChannelHandlerContext ctx) throws Exception {
  if (logger.isDebugEnabled()) {
    logger.debug("RequestUri : [{}]", request.getUri());
  }
  final String pathWithoutPrefix = request.getUri().replaceFirst(factory.config().prefix(), "");
  final String path = new QueryStringDecoder(pathWithoutPrefix).path();
  if (Greeting.matches(path)) {
    writeResponse(ctx.channel(), request, Greeting.response(request));
  } else if (Info.matches(path)) {
    writeResponse(ctx.channel(), request, Info.response(factory.config(), request));
  } else if (Iframe.matches(path)) {
    writeResponse(ctx.channel(), request, Iframe.response(factory.config(), request));
  } else if (Transports.Type.WEBSOCKET.path().equals(path)) {
    addTransportHandler(new RawWebSocketTransport(factory.config(), factory.create()), ctx);
    ctx.fireChannelRead(request.retain());
  } else {
    final PathParams sessionPath = matches(path);
    if (sessionPath.matches()) {
      handleSession(factory, request, ctx, sessionPath);
    } else {
      writeNotFoundResponse(request, ctx);
    }
  }
}
origin: aerogear/aerogear-simplepush-server

switch (pathParams.transport()) {
case XHR:
  addTransportHandler(new XhrPollingTransport(factory.config(), request), ctx);
  addSessionHandler(new PollingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case JSONP:
  addTransportHandler(new JsonpPollingTransport(factory.config(), request), ctx);
  addSessionHandler(new PollingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case XHR_SEND:
  checkSessionExists(pathParams.sessionId(), request);
  addTransportHandler(new XhrSendTransport(factory.config()), ctx);
  addSessionHandler(new SendingSessionState(sessions, sessions.get(pathParams.sessionId())), ctx);
  break;
case XHR_STREAMING:
  addTransportHandler(new XhrStreamingTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case EVENTSOURCE:
  addTransportHandler(new EventSourceTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case HTMLFILE:
  addTransportHandler(new HtmlFileTransport(factory.config(), request), ctx);
  addSessionHandler(new StreamingSessionState(sessions, getSession(factory, pathParams.sessionId())), ctx);
  break;
case JSONP_SEND:
  checkSessionExists(pathParams.sessionId(), request);
  addTransportHandler(new JsonpSendTransport(factory.config()), ctx);
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  if (cause instanceof SessionNotFoundException) {
    final SessionNotFoundException se = (SessionNotFoundException) cause;
    logger.debug("Could not find session [{}]", se.sessionId());
    writeNotFoundResponse(se.httpRequest(), ctx);
  } else {
    logger.error("exception caught:", cause);
    ctx.fireExceptionCaught(cause);
  }
}
origin: aerogear/aerogear-simplepush-server

@Override
protected void initChannel(final SocketChannel socketChannel) throws Exception {
  final ChannelPipeline pipeline = socketChannel.pipeline();
  if (sockjsConfig.isTls()) {
    final SSLEngine engine = sslContext.createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast(new SslHandler(engine));
  }
  pipeline.addLast(new HttpServerCodec());
  pipeline.addLast(new HttpObjectAggregator(65536));
  final DefaultSimplePushServer simplePushServer = new DefaultSimplePushServer(datastore, simplePushConfig, privateKey);
  pipeline.addLast(new NotificationHandler(simplePushServer));
  pipeline.addLast(new CorsInboundHandler());
  pipeline.addLast(new SockJsHandler(new SimplePushServiceFactory(sockjsConfig, simplePushServer)));
  pipeline.addLast(backgroundGroup, new UserAgentReaperHandler(simplePushServer));
  pipeline.addLast(new CorsOutboundHandler());
}
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

@Override
public void messageReceived(final ChannelHandlerContext ctx, final FullHttpRequest request) throws Exception {
  final String path = new QueryStringDecoder(request.getUri()).path();
  for (SockJsServiceFactory factory : factories.values()) {
    if (path.startsWith(factory.config().prefix())) {
      handleService(factory, request, ctx);
      return;
    }
  }
  writeNotFoundResponse(request, ctx);
}
origin: org.jboss.aerogear/aerogear-netty-codec-sockjs

private static void writeNotFoundResponse(final HttpRequest request, final ChannelHandlerContext ctx) {
  final FullHttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(), NOT_FOUND,
      Unpooled.copiedBuffer("Not found", CharsetUtil.UTF_8));
  writeResponse(ctx.channel(), request, response);
}
org.jboss.aerogear.io.netty.handler.codec.sockjs.handlerSockJsHandler

Javadoc

This handler is the main entry point for SockJS HTTP Request. It is responsible for inspecting the request uri and adding ChannelHandlers for different transport protocols that SockJS support. Once this has been done this handler will be removed from the channel pipeline.

Most used methods

  • <init>
    Sole constructor which takes one or more SockJSServiceFactory. These factories will later be used by
  • addSessionHandler
  • addTransportHandler
  • checkSessionExists
  • getSession
  • handleService
  • handleSession
  • matches
  • writeNotFoundResponse
  • writeResponse

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ImageIO (javax.imageio)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now