Tabnine Logo
NettyWebSocket
Code IndexAdd Tabnine to your IDE (free)

How to use
NettyWebSocket
in
org.atmosphere.nettosphere

Best Java code snippets using org.atmosphere.nettosphere.NettyWebSocket (Showing top 10 results out of 315)

origin: Atmosphere/nettosphere

/**
 * {@inheritDoc}
 */
@Override
public WebSocket write(byte[] data, int offset, int length) throws IOException {
  _write(data, offset, length);
  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: 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());
  }
}
origin: Atmosphere/nettosphere

  wsFactory.sendUnsupportedVersionResponse(ctx.channel());
} else {
  final NettyWebSocket webSocket = new NettyWebSocket(ctx.channel(), framework.getAtmosphereConfig(), config.noInternalAlloc(), config.binaryWrite());
  final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY);
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/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());
  }
}
origin: org.atmosphere/nettosphere

  wsFactory.sendUnsupportedVersionResponse(ctx.channel());
} else {
  final NettyWebSocket webSocket = new NettyWebSocket(ctx.channel(), framework.getAtmosphereConfig(), config.noInternalAlloc(), config.binaryWrite());
  final AtmosphereRequest atmosphereRequest = createAtmosphereRequest(ctx, request, EMPTY);
origin: org.atmosphere/nettosphere

public WebSocket write(byte[] data) throws IOException {
  _write(data, 0, data.length);
  return this;
}
origin: org.atmosphere/nettosphere

/**
 * {@inheritDoc}
 */
@Override
public WebSocket write(byte[] data, int offset, int length) throws IOException {
  _write(data, offset, length);
  return this;
}
origin: Atmosphere/nettosphere

public WebSocket write(byte[] data) throws IOException {
  _write(data, 0, data.length);
  return this;
}
org.atmosphere.nettosphereNettyWebSocket

Most used methods

  • <init>
  • _write
  • close
  • closeFuture
  • lastWriteTimeStampInMilliseconds
  • resource
  • uuid

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • addToBackStack (FragmentTransaction)
  • getExternalFilesDir (Context)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • From CI to AI: The AI layer in your organization
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