本文整理汇总了Java中io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator类的典型用法代码示例。如果您正苦于以下问题:Java WebSocketFrameAggregator类的具体用法?Java WebSocketFrameAggregator怎么用?Java WebSocketFrameAggregator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebSocketFrameAggregator类属于io.netty.handler.codec.http.websocketx包,在下文中一共展示了WebSocketFrameAggregator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: channelRead0
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext context, Object message) throws Exception {
final Channel channel = context.channel();
if (!handshaker.isHandshakeComplete()) {
handshaker.finishHandshake(channel, (FullHttpResponse) message);
channel.pipeline().addBefore(HANDLER_NAME, "websocket-frame-aggregator", new WebSocketFrameAggregator(64 * 1024));
subscriber.onStart();
return;
}
if (message instanceof FullHttpResponse) {
final FullHttpResponse response = (FullHttpResponse) message;
throw new IllegalStateException(
"Unexpected FullHttpResponse (getStatus=" + response.getStatus() +
", content=" + response.content().toString(CharsetUtil.UTF_8) + ')');
}
final WebSocketFrame frame = (WebSocketFrame) message;
if (frame instanceof PingWebSocketFrame) {
context.writeAndFlush(new PongWebSocketFrame(((PingWebSocketFrame)frame).retain().content()));
} else if (frame instanceof BinaryWebSocketFrame) {
final ByteBufInputStream input = new ByteBufInputStream(((BinaryWebSocketFrame)message).content());
final Envelope envelope = Envelope.ADAPTER.decode(input);
subscriber.onNext(envelope);
}
}
开发者ID:cloudfoundry-community,项目名称:snotel,代码行数:27,代码来源:NettyFirehoseOnSubscribe.java
示例2: handshake
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
private void handshake(final ChannelHandlerContext ctx, final FullHttpRequest req, final String requestPath) {
WebSocketServerHandshakerFactory wsFactory =
new WebSocketServerHandshakerFactory(getWebSocketLocation(req), null, true, maxWebSocketFrameSize);
WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(req);
if (handshaker != null) {
handshaker.handshake(ctx.channel(), req).addListener(
new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
final String sessionId = PipelineUtils.getSessionId(requestPath);
if (future.isSuccess()) {
ctx.channel().pipeline().addBefore(
SocketIOChannelInitializer.SOCKETIO_WEBSOCKET_HANDLER,
SocketIOChannelInitializer.WEBSOCKET_FRAME_AGGREGATOR,
new WebSocketFrameAggregator(maxWebSocketFrameSize));
connect(ctx, req, sessionId);
} else {
log.error("Can't handshake: {}", sessionId, future.cause());
}
}
});
} else {
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
}
}
开发者ID:scalecube,项目名称:socketio,代码行数:26,代码来源:WebSocketHandler.java
示例3: handleWebSocketRequest
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
private void handleWebSocketRequest(@NotNull final ChannelHandlerContext context, @NotNull FullHttpRequest request, @NotNull final QueryStringDecoder uriDecoder) {
WebSocketServerHandshakerFactory factory = new WebSocketServerHandshakerFactory("ws://" + request.headers().getAsString(HttpHeaderNames.HOST) + uriDecoder.path(), null, false, NettyUtil.MAX_CONTENT_LENGTH);
WebSocketServerHandshaker handshaker = factory.newHandshaker(request);
if (handshaker == null) {
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(context.channel());
return;
}
if (!context.channel().isOpen()) {
return;
}
final Client client = new WebSocketClient(context.channel(), handshaker);
context.attr(ClientManager.CLIENT).set(client);
handshaker.handshake(context.channel(), request).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
ClientManager clientManager = WebSocketHandshakeHandler.this.clientManager.getValue();
clientManager.addClient(client);
MessageChannelHandler messageChannelHandler = new MessageChannelHandler(clientManager, getMessageServer());
BuiltInServer.replaceDefaultHandler(context, messageChannelHandler);
ChannelHandlerContext messageChannelHandlerContext = context.pipeline().context(messageChannelHandler);
context.pipeline().addBefore(messageChannelHandlerContext.name(), "webSocketFrameAggregator", new WebSocketFrameAggregator(NettyUtil.MAX_CONTENT_LENGTH));
messageChannelHandlerContext.attr(ClientManager.CLIENT).set(client);
connected(client, uriDecoder.parameters());
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:WebSocketHandshakeHandler.java
示例4: initChannel
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel ch) throws Exception {
decoder = new WebsocketProtostuffDecoder(handShaker);
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("http-client", new HttpClientCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(C5Constants.MAX_RESPONSE_SIZE));
pipeline.addLast("websec-codec", new WebsocketProtostuffEncoder(handShaker));
pipeline.addLast("websocket-aggregator", new WebSocketFrameAggregator(C5Constants.MAX_RESPONSE_SIZE));
pipeline.addLast("message-codec", decoder);
pipeline.addLast("message-handler", new FutureBasedMessageHandler());
}
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:12,代码来源:C5ConnectionInitializer.java
示例5: upgradePipelineForWebSockets
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
public void upgradePipelineForWebSockets(ChannelPipeline pipeline) {
pipeline.addAfter(HTTP_CLIENT_CODEC, WS_ENCODER_HANDLER, new WebSocket08FrameEncoder(true));
pipeline.addBefore(AHC_WS_HANDLER, WS_DECODER_HANDLER, new WebSocket08FrameDecoder(false, false, config.getWebSocketMaxFrameSize()));
pipeline.addAfter(WS_DECODER_HANDLER, WS_FRAME_AGGREGATOR, new WebSocketFrameAggregator(config.getWebSocketMaxBufferSize()));
pipeline.remove(HTTP_CLIENT_CODEC);
}
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:7,代码来源:ChannelManager.java
示例6: doStart
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
@Override
protected void doStart() {
fiber.start();
fiber.execute(() -> {
// we need the tablet module:
ListenableFuture<C5Module> f = server.getModule(ModuleType.Tablet);
Futures.addCallback(f, new FutureCallback<C5Module>() {
@Override
public void onSuccess(final C5Module result) {
tabletModule = (TabletModule) result;
bootstrap.group(acceptGroup, workerGroup)
.option(ChannelOption.SO_REUSEADDR, true)
.childOption(ChannelOption.TCP_NODELAY, true)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast("http-server-codec", new HttpServerCodec());
p.addLast("http-agg", new HttpObjectAggregator(C5ServerConstants.MAX_CALL_SIZE));
p.addLast("websocket-agg", new WebSocketFrameAggregator(C5ServerConstants.MAX_CALL_SIZE));
p.addLast("decoder", new WebsocketProtostuffDecoder("/websocket"));
p.addLast("encoder", new WebsocketProtostuffEncoder());
p.addLast("handler", new RegionServerHandler(RegionServerService.this));
}
}
);
bootstrap.bind(port).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
listenChannel = future.channel();
notifyStarted();
} else {
LOG.error("Unable to find Region Server to {} {}", port, future.cause());
notifyFailed(future.cause());
}
}
});
}
@Override
public void onFailure(Throwable t) {
notifyFailed(t);
}
}, fiber);
});
}
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:51,代码来源:RegionServerService.java
示例7: aggregateFrames
import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; //导入依赖的package包/类
/**
* Turn this {@link WebsocketInbound} into aggregating mode which will only produce
* fully formed frame that have been received fragmented.
*
* @param maxContentLength the maximum frame length
*
* @return this inbound
*/
default WebsocketInbound aggregateFrames(int maxContentLength) {
context().addHandlerLast(new WebSocketFrameAggregator(maxContentLength));
return this;
}
开发者ID:reactor,项目名称:reactor-netty,代码行数:13,代码来源:WebsocketInbound.java
注:本文中的io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论