Codota Logo
WebSocketProcessor
Code IndexAdd Codota to your IDE (free)

How to use
WebSocketProcessor
in
org.atmosphere.websocket

Best Java code snippets using org.atmosphere.websocket.WebSocketProcessor (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: Atmosphere/atmosphere

@Override
public void onClose(javax.websocket.Session session, javax.websocket.CloseReason closeCode) {
  logger.trace("{} closed {}", session, closeCode);
  if (request != null) {
    request.destroy();
    webSocketProcessor.close(webSocket, closeCode.getCloseCode().getCode());
  }
}
origin: Atmosphere/atmosphere

    .queryString(session.getQueryString());
if (!webSocketProcessor.handshake(request)) {
  try {
    session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Handshake not accepted."));
webSocketProcessor.open(webSocket, request, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), request, webSocket));
origin: Atmosphere/atmosphere

  @Override
  public void onError(javax.websocket.Session session, java.lang.Throwable t) {
    try {
      logger.debug("Problem in web socket session", t);
      webSocketProcessor.notifyListener(webSocket,
          new WebSocketEventListener.WebSocketEvent<Throwable>(t, WebSocketEventListener.WebSocketEvent.TYPE.EXCEPTION, webSocket));
    } catch (Exception ex) {
      // Ignore completely
      // https://github.com/Atmosphere/atmosphere/issues/1758
    }
  }
}
origin: Atmosphere/atmosphere-vertx

  webSocketProcessor.open(w, r, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), r, w));
} catch (IOException e) {
  logger.debug("", e);
webSocket.closeHandler(aVoid -> {
  w.close();
  webSocketProcessor.close(w, 1005);
});
return this;
origin: Atmosphere/nettosphere

  @Override
  public void operationComplete(ChannelFuture future) throws Exception {
    if (!future.isSuccess()) {
      future.channel().close();
    } else {
      websocketChannels.add(ctx.channel());
      ctx.channel().attr(ATTACHMENT).set(webSocket);
      if (config.noInternalAlloc()) {
        webSocket.resource(proxiedResource);
      }
      AtmosphereResponse response = config.noInternalAlloc() ? proxiedResponse :
          AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), atmosphereRequest, webSocket);
      webSocketProcessor.open(webSocket, atmosphereRequest, response);
      if (webSocketTimeout > 0) {
        webSocket.closeFuture(suspendTimer.scheduleAtFixedRate(() -> {
          if (webSocket.lastWriteTimeStampInMilliseconds() != 0 && (System.currentTimeMillis() - webSocket.lastWriteTimeStampInMilliseconds() > webSocketTimeout)) {
            logger.debug("Timing out {}", webSocket);
            webSocket.close();
          }
        }, webSocketTimeout, webSocketTimeout, TimeUnit.MILLISECONDS));
      }
    }
  }
});
origin: Atmosphere/atmosphere-play

private void handleString(String string) {
  this.webSocketProcessor.invokeWebSocketProtocol(this.playWebSocket, string);
}
origin: Atmosphere/nettosphere

final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY);
if (!webSocketProcessor.handshake(atmosphereRequest)) {
  sendError(ctx, HttpResponseStatus.BAD_REQUEST, null);
  return;
webSocketProcessor.notifyListener(webSocket, new WebSocketEventListener.WebSocketEvent("", HANDSHAKE, webSocket));
origin: Atmosphere/atmosphere

public synchronized void destroy() {
  for (WebSocketProcessor processor : processors.values()) {
    processor.destroy();
  }
  processors.clear();
}
origin: Atmosphere/atmosphere

  private WebSocketProcessor createProcessor(AtmosphereFramework framework) {
    WebSocketProcessor processor = null;

    String webSocketProcessorName = framework.getWebSocketProcessorClassName();
    if (!webSocketProcessorName.equalsIgnoreCase(DefaultWebSocketProcessor.class.getName())) {
      try {
        processor =  framework.newClassInstance(WebSocketProcessor.class,
            (Class<WebSocketProcessor>) IOUtils.loadClass(getClass(), webSocketProcessorName));
      } catch (Exception ex) {
        logger.error("Unable to create {}", webSocketProcessorName);
        processor = new DefaultWebSocketProcessor();
      }
    }

    if (processor == null) {
      processor = new DefaultWebSocketProcessor();
    }
    processor.configure(framework.getAtmosphereConfig());

    return processor;
  }
}
origin: org.atmosphere/nettosphere

  @Override
  public void operationComplete(ChannelFuture future) throws Exception {
    if (!future.isSuccess()) {
      future.channel().close();
    } else {
      websocketChannels.add(ctx.channel());
      ctx.channel().attr(ATTACHMENT).set(webSocket);
      if (config.noInternalAlloc()) {
        webSocket.resource(proxiedResource);
      }
      AtmosphereResponse response = config.noInternalAlloc() ? proxiedResponse :
          AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), atmosphereRequest, webSocket);
      webSocketProcessor.open(webSocket, atmosphereRequest, response);
      if (webSocketTimeout > 0) {
        webSocket.closeFuture(suspendTimer.scheduleAtFixedRate(() -> {
          if (webSocket.lastWriteTimeStampInMilliseconds() != 0 && (System.currentTimeMillis() - webSocket.lastWriteTimeStampInMilliseconds() > webSocketTimeout)) {
            logger.debug("Timing out {}", webSocket);
            webSocket.close();
          }
        }, webSocketTimeout, webSocketTimeout, TimeUnit.MILLISECONDS));
      }
    }
  }
});
origin: Atmosphere/atmosphere-vertx

  @Override
  public void handle(Buffer data) {
    webSocketProcessor.invokeWebSocketProtocol(w, data.toString());
  }
});
origin: org.atmosphere/nettosphere

final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY);
if (!webSocketProcessor.handshake(atmosphereRequest)) {
  sendError(ctx, HttpResponseStatus.BAD_REQUEST, null);
  return;
webSocketProcessor.notifyListener(webSocket, new WebSocketEventListener.WebSocketEvent("", HANDSHAKE, webSocket));
origin: Atmosphere/atmosphere

void patchGlassFish(NullPointerException e) {
  // https://java.net/jira/browse/TYRUS-175
  logger.trace("", e);
  WebSocketProcessorFactory.getDefault().getWebSocketProcessor(config().framework()).close(this, 1002);
}
origin: Atmosphere/atmosphere-play

@Override
public void preStart() {
  try {
    this.playWebSocket = new PlayWebSocket(actorRef, atmosphereConfig);
    this.webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(atmosphereConfig.framework());
    AtmosphereRequest atmosphereRequest = AtmosphereUtils.request(new Http.RequestImpl(requestHeader), additionalAttributes);
    this.webSocketProcessor.open(playWebSocket, atmosphereRequest, AtmosphereResponseImpl.newInstance(atmosphereConfig, atmosphereRequest, playWebSocket));
  } catch (Throwable throwable) {
    LOG.error("Failed to start the actor ", throwable);
  }
}
origin: Atmosphere/atmosphere-play

private void handleByteString(ByteString byteString) {
  this.webSocketProcessor.invokeWebSocketProtocol(this.playWebSocket, byteString.toString());
}
origin: Atmosphere/atmosphere-play

@Override
public void postStop() {
  this.webSocketProcessor.close(playWebSocket, 1002);
}
origin: org.atmosphere/nettosphere

  webSocketProcessor.invokeWebSocketProtocol(attachment, body, 0, body.length);
} else if (frame instanceof TextWebSocketFrame) {
  webSocketProcessor.invokeWebSocketProtocol(attachment, ((TextWebSocketFrame) frame).text());
} else if (frame instanceof PongWebSocketFrame) {
origin: Atmosphere/atmosphere-vertx

  @Override
  public void handle(Throwable event) {
    w.close();
    logger.debug("", event);
    webSocketProcessor.close(w, 1006);
  }
});
origin: Atmosphere/nettosphere

  webSocketProcessor.invokeWebSocketProtocol(attachment, body, 0, body.length);
} else if (frame instanceof TextWebSocketFrame) {
  webSocketProcessor.invokeWebSocketProtocol(attachment, ((TextWebSocketFrame) frame).text());
} else if (frame instanceof PongWebSocketFrame) {
origin: org.atmosphere/nettosphere

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
  super.channelInactive(ctx);
  Object o = ctx.attr(ATTACHMENT).get();
  if (o == null) return;
  if (WebSocket.class.isAssignableFrom(o.getClass())) {
    NettyWebSocket webSocket = NettyWebSocket.class.cast(o);
    logger.trace("Closing {}", webSocket.uuid());
    try {
      if (webSocket.closeFuture() != null) {
        webSocket.closeFuture().cancel(true);
      }
      webSocketProcessor.close(webSocket, 1005);
    } catch (Exception ex) {
      logger.error("{}", webSocket, ex);
    }
  } else if (State.class.isAssignableFrom(o.getClass())) {
    logger.trace("State {}", o);
    State s = State.class.cast(o);
    if (s.action.type() == Action.TYPE.SUSPEND) {
      asynchronousProcessor.endRequest(s.resource(), true);
    }
  } else {
    logger.warn("Invalid state {} and Channel {}", o, ctx.channel());
  }
}
org.atmosphere.websocketWebSocketProcessor

Javadoc

Atmosphere's WebSocket Support implementation. The default behavior is implemented in DefaultWebSocketProcessor. This class is targeted at framework developer as it requires Atmosphere's internal knowledge.
This class can also be used to implement the JSR 345 recommendation.

Most used methods

  • close
  • open
    Invoked when a WebSocket gets opened by the underlying container
  • invokeWebSocketProtocol
  • handshake
  • notifyListener
  • configure
    Configure, or post construct a WebSocketProcessor
  • destroy
    Destroy all resources associated with this class.
  • registerWebSocketHandler
    Register a WebSocketHandler

Popular in Java

  • Running tasks concurrently on multiple threads
  • notifyDataSetChanged (ArrayAdapter)
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now