为什么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)[2022-09-04]
在隐藏当前控件之前,将焦点更改为可见控件之一 Private Sub button3_click() 'show submenu buttons button4.Visible = True button5.Visible = True DoEvents 'execute any pending events, to make sure the button 4 and 5 are really visible button4.SetFocus ... -
我猜你不是故意这样做: if (control.Style["display"] == "none") { .... } 你想在回发后想知道吗? 如果是这种情况,那么你不能这样做,除非你使用JavaScript存储它隐藏在隐藏输入或类似内容中的事实。 I'm guessing you don't mean just doing: if (control.Style["display"] == "none") { .... } And that you want to know after a postb ...
-
如果您使用autolayout,有两个选项 选项1:如果您不想在隐藏它后在视图中保留段控件,请为表视图底边添加约束,将其设置为常量0并将优先级设置为高(或者低于tableview和段控制的任何值) )。 现在,从superview中删除段控件。(参考这里 ) 选项2:为tableview底部交易添加约束并将其常量设置为某个高度,从而为分段控制提供足够的空间。 然后将布局约束与IBOutlet连接。 当你想要隐藏分段控件时,隐藏它并将布局约束的常量设置为0。 If you are using autolayo ...
-
如何隐藏表单控件并只需要表单控件元素的值(how to hide form control and want only value of form control elements)[2022-09-18]
通过使用form-group元素的CSS display属性,您可以轻松地隐藏所需的元素。 这可以像下面这样实现: