• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java WebSocketHandshakeException类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中io.netty.handler.codec.http.websocketx.WebSocketHandshakeException的典型用法代码示例。如果您正苦于以下问题:Java WebSocketHandshakeException类的具体用法?Java WebSocketHandshakeException怎么用?Java WebSocketHandshakeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WebSocketHandshakeException类属于io.netty.handler.codec.http.websocketx包,在下文中一共展示了WebSocketHandshakeException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: channelRead0

点赞 3

import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException; //导入依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext context, Object message) throws Exception {
  Channel channel = context.channel();
  if (message instanceof FullHttpResponse) {
    checkState(!handshaker.isHandshakeComplete());
    try {
      handshaker.finishHandshake(channel, (FullHttpResponse) message);
      delegate.onOpen();
    } catch (WebSocketHandshakeException e) {
      delegate.onError(e);
    }
  } else if (message instanceof TextWebSocketFrame) {
    delegate.onMessage(((TextWebSocketFrame) message).text());
  } else {
    checkState(message instanceof CloseWebSocketFrame);
    delegate.onClose();
  }
}
 

开发者ID:firebase,
项目名称:firebase-admin-java
代码行数:19,
代码来源:NettyWebSocketClient.java

示例2: exceptionCaught

点赞 2

import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (cause instanceof WebSocketHandshakeException) {
        sendBadRequestAndClose(ctx, cause.getMessage());
    } else {
        ctx.close();
    }
}
 

开发者ID:Matthias247,
项目名称:jawampa,
代码行数:9,
代码来源:WampServerWebsocketHandler.java

示例3: onInboundNext

点赞 2

import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void onInboundNext(ChannelHandlerContext ctx, Object msg) {
	if (msg instanceof FullHttpResponse) {
		started = true;
		channel().pipeline()
		         .remove(HttpObjectAggregator.class);
		FullHttpResponse response = (FullHttpResponse) msg;

		setNettyResponse(response);

		if (checkResponseCode(response)) {

			try {
				if (!handshaker.isHandshakeComplete()) {
					handshaker.finishHandshake(channel(), response);
				}
			}
			catch (WebSocketHandshakeException wshe) {
				if (serverError) {
					onInboundError(wshe);
					return;
				}
			}

			parentContext().fireContextActive(this);
			handshakerResult.trySuccess();
		}
		return;
	}
	if (msg instanceof PingWebSocketFrame) {
		channel().writeAndFlush(new PongWebSocketFrame(((PingWebSocketFrame) msg).content()));
		ctx.read();
		return;
	}
	if (msg instanceof CloseWebSocketFrame &&
			((CloseWebSocketFrame)msg).isFinalFragment()) {
		if (log.isDebugEnabled()) {
			log.debug("CloseWebSocketFrame detected. Closing Websocket");
		}

		CloseWebSocketFrame close = (CloseWebSocketFrame) msg;
		sendClose(new CloseWebSocketFrame(true,
				close.rsv(),
				close.content()));
	}
	else {
		super.onInboundNext(ctx, msg);
	}
}
 

开发者ID:reactor,
项目名称:reactor-netty,
代码行数:51,
代码来源:HttpClientWSOperations.java

示例4: exceptionCaught

点赞 2

import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (cause instanceof WebSocketHandshakeException) {
        log.debug("Web Socket Handshake Exception.", cause);
    }
}
 

开发者ID:blynkkk,
项目名称:blynk-server,
代码行数:7,
代码来源:WebSocketHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)