List of usage examples for io.netty.util AttributeKey valueOf
@SuppressWarnings("unchecked") public static <T> AttributeKey<T> valueOf(String name)
From source file:org.wso2.carbon.mss.internal.router.HttpDispatcher.java
License:Open Source License
@Override protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws HandlerException { Object httpMethodInfoBuilderObj = ctx.pipeline().context(RequestRouter.class) .attr(AttributeKey.valueOf(RequestRouter.METHOD_INFO_BUILDER)).get(); if (httpMethodInfoBuilderObj instanceof HttpMethodInfoBuilder) { httpMethodInfoBuilder = (HttpMethodInfoBuilder) httpMethodInfoBuilderObj; if (msg instanceof FullHttpRequest) { FullHttpRequest fullHttpRequest = (FullHttpRequest) msg; httpMethodInfoBuilder.httpRequest(fullHttpRequest).build().invoke(); } else if (msg instanceof HttpContent) { httpMethodInfoBuilder.build().chunk((HttpContent) msg); }/*from w w w.j ava 2 s . co m*/ } }
From source file:org.wso2.carbon.mss.internal.router.RequestRouter.java
License:Open Source License
private boolean handleRequest(HttpRequest httpRequest, Channel channel, ChannelHandlerContext ctx) throws HandlerException { httpMethodInfoBuilder = httpMethodHandler.getDestinationMethod(httpRequest, new BasicHttpResponder(channel, HttpHeaders.isKeepAlive(httpRequest))); ctx.attr(AttributeKey.valueOf(METHOD_INFO_BUILDER)).set(httpMethodInfoBuilder); return httpMethodInfoBuilder != null; }
From source file:preformance_test.handler.WebSocketServerHandler.java
License:Apache License
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) { // Check for closing frame if (frame instanceof CloseWebSocketFrame) { Object userId = ctx.channel().attr(AttributeKey.valueOf("userId")).get(); TestCenter.removeConnection(userId); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain()); return;// ww w .j a v a2s. com } if (frame instanceof PingWebSocketFrame) { // ping/pong System.out.println("ping: " + frame); ctx.write(new PongWebSocketFrame(frame.content().retain())); return; } if (frame instanceof TextWebSocketFrame) { // Echo the frame //??websocket ctx.channel().write(new TextWebSocketFrame(((TextWebSocketFrame) frame).text() + ", Netty WebSocket? :" + new java.util.Date().toString())); return; } // ??? if (frame instanceof BinaryWebSocketFrame) { // Echo the frame ctx.write(frame.retain()); } }