本文整理汇总了Java中io.netty.handler.codec.http.FullHttpRequest.retain方法的典型用法代码示例。如果您正苦于以下问题:Java FullHttpRequest.retain方法的具体用法?Java FullHttpRequest.retain怎么用?Java FullHttpRequest.retain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.FullHttpRequest
的用法示例。
在下文中一共展示了FullHttpRequest.retain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception {
msg.retain();
out.add(msg);
// If the session cookie exists, set its value on the ctx.
final String sessionId = HttpRequestDecoder.getSessionId(msg, this.anonymousAccessAllowed);
ctx.channel().attr(SESSION_ID_ATTR).set(sessionId);
LOG.info("Found session id in WebSocket channel, setting sessionId {} on context", sessionId);
}
示例2: channelRead0
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
public void channelRead0(final ChannelHandlerContext ctx, final FullHttpRequest msg) throws Exception {
final Channel inboundChannel = ctx.channel();
String host = msg.headers().get("Host");
int port = 80;
String pattern = "(http://|https://)?([^:]+)(:[\\d]+)?";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(host);
if (m.find()) {
host = m.group(2);
port = (m.group(3) == null) ? 80 : Integer.parseInt(m.group(3).substring(1));
}
Bootstrap b = new Bootstrap();
b.group(inboundChannel.eventLoop()) // use inboundChannel thread
.channel(ctx.channel().getClass())
.handler(new BackendHandlerInitializer(inboundChannel));
ChannelFuture f = b.connect(host, port);
outboundChannel = f.channel();
msg.retain();
f.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
outboundChannel.writeAndFlush(msg);
} else {
inboundChannel.close();
}
}
});
}
示例3: decode
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception {
msg.retain();
out.add(msg);
// If the session cookie exists, set its value on the ctx.
final String sessionId = HttpRequestDecoder.getSessionId(msg, this.anonymousAccessAllowed);
ctx.channel().attr(SubscriptionRegistry.SESSION_ID_ATTR).set(sessionId);
LOG.info("Found session id in WebSocket channel, setting sessionId {} on context", sessionId);
}
示例4: encode
import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception {
msg.retain();
out.add(msg);
}