protected override void ChannelRead0(IChannelHandlerContext ctx, IFullHttpRequest request) { QueryStringDecoder queryString = new QueryStringDecoder(request.Uri); string streamId = StreamId(request); int latency = Http2ExampleUtil.ToInt(Http2ExampleUtil.FirstValue(queryString, LATENCY_FIELD_NAME), 0); if (latency < MIN_LATENCY || latency > MAX_LATENCY) { SendBadRequest(ctx, streamId); return; } string x = Http2ExampleUtil.FirstValue(queryString, IMAGE_COORDINATE_X); string y = Http2ExampleUtil.FirstValue(queryString, IMAGE_COORDINATE_Y); if (x == null || y == null) { HandlePage(ctx, streamId, latency, request); } else { HandleImage(x, y, ctx, streamId, latency, request); } }
static ImageCache() { ImageBank = new Dictionary <string, IByteBuffer>(StringComparer.OrdinalIgnoreCase); var asm = typeof(ImageCache).Assembly; var path = typeof(ImageCache).Namespace + ".images."; for (int y = 0; y < 10; y++) { for (int x = 0; x < 20; x++) { try { string name = Name(x, y); var fileBytes = Unpooled.UnreleasableBuffer(Http2ExampleUtil.ToByteBuffer(asm.GetManifestResourceStream(path + name))); ImageBank.Add(name, fileBytes); } catch (Exception) { //e.printStackTrace(); } } } }