为什么netty http2服务器总是使用奇数来表示streamId(Why netty http2 server always use odd number for streamId)
我正在使用Netty来设置一个简单的http / 2服务器。 我将此示例用作http / 2服务器。
要测试此服务器,我使用的是netty示例客户端 。
我将客户端代码发送到服务器的客户端代码:
完整代码: http : //netty.io/5.0/xref/io/netty/example/http2/client/package-summary.htmlHttpResponseHandler responseHandler = initializer.responseHandler(); int streamId = 3; HttpScheme scheme = SSL ? HttpScheme.HTTPS : HttpScheme.HTTP; AsciiString hostName = new AsciiString(HOST + ':' + PORT); System.out.println("Sending request(s)..."); if (URL != null) { System.out.println("with url"); // Create a simple GET request. FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, URL); request.headers().add(HttpHeaderNames.HOST, hostName); request.headers().add(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), scheme.name()); request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP); request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.DEFLATE); responseHandler.put(streamId, channel.writeAndFlush(request), channel.newPromise()); streamId += 2; }
上面的代码适用于流ID 3,5等。
但是,当我将流ID更改为任何其他数字,如4,6,8等,上面的代码不起作用。 从服务器我仍然得到流ID为3,5,7等的消息。我无法在示例服务器中找到这些流ID的逻辑I am using Netty to setup a simple http/2 server. I am using this example as http/2 server.
To test this server, I am using netty example client.
My client code where I am sending the request to server:
Complete code : http://netty.io/5.0/xref/io/netty/example/http2/client/package-summary.htmlHttpResponseHandler responseHandler = initializer.responseHandler(); int streamId = 3; HttpScheme scheme = SSL ? HttpScheme.HTTPS : HttpScheme.HTTP; AsciiString hostName = new AsciiString(HOST + ':' + PORT); System.out.println("Sending request(s)..."); if (URL != null) { System.out.println("with url"); // Create a simple GET request. FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, URL); request.headers().add(HttpHeaderNames.HOST, hostName); request.headers().add(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), scheme.name()); request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP); request.headers().add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.DEFLATE); responseHandler.put(streamId, channel.writeAndFlush(request), channel.newPromise()); streamId += 2; }
Above code works fine with stream id 3,5 and so on.
But when i change the stream id to any other number like 4,6,8 etc, above code doesn't work. From server I still get the messages for stream id 3,5,7 etc. I am unable to find the logic for these stream id inside example server
原文:https://stackoverflow.com/questions/43550116
满意答案
如果查看Grid和Split布局的默认Visual Studio模板,您将找到一个值转换器的示例,它根据布尔值设置控件可见性。 代码显示在这里
public sealed class BooleanToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) { return value is Visibility && (Visibility)value == Visibility.Visible; } }
您需要的只是复制此代码并修改它以基于整数值设置visibility属性 - 例如IntToVisibilityConverter。 您可以在想要受影响的控件上使用这样的转换器
Visibility="{Binding IsActive, Converter={StaticResource IntToVisibilityConverter}}"
If you look at the default Visual Studio Templates for Grid and Split layouts, you will find an example of a value converter that sets a controls visibility based on a Boolean value. The code is shown here
public sealed class BooleanToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) { return value is Visibility && (Visibility)value == Visibility.Visible; } }
All you would need to is copy this code and modify it to set the visibility property based on an integer value - IntToVisibilityConverter, for example. You would use the converter like this on the control you wanted to be affected
Visibility="{Binding IsActive, Converter={StaticResource IntToVisibilityConverter}}"
相关问答
更多如何隐藏VBA中的按钮控件(How to hide button control in VBA)
检查是否已使用.hide隐藏控件(check to see if a control has been hidden with .hide)
如何隐藏段控件并展开UITableView?(How to hide segment control and expand UITableView?)
如何隐藏表单控件并只需要表单控件元素的值(how to hide form control and want only value of form control elements)
我可以在NumericUpDown控件中隐藏值吗?(Can I hide Value in NumericUpDown control?)
如何使用jquery显示/隐藏Fileuploader控件?(How to show/hide Fileuploader control using jquery?)
如果值为0,如何隐藏控件?(How to hide control if value is 0?)
隐藏WebBrowser控件(Hide WebBrowser control)
隐藏LostFocus上的控件(Hide control on LostFocus)
RDLC根据字段值显示/隐藏控件(RDLC Show/Hide control base on a field value)
相关文章
更多[Netty 1] 初识Netty
Netty源码分析
Netty开发环境配置
Netty入门实例-时间服务器
storm学习之Netty代替ZMQ
Netty入门实例-编写服务器端程序
在Twitter,Netty 4 GC开销降为五分之一
Netty基于流的传输处理
Java Number类
Netty入门实例-使用POJO代替ByteBuf
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!