congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
WebSocketProcessor
Code IndexAdd Tabnine 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)

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

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Menu (java.awt)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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