为什么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.html

    HttpResponseHandler 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.html

    HttpResponseHandler 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
2022-10-09 16:10

满意答案

如果查看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)

在隐藏当前控件之前,将焦点更改为可见控件之一 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.SetF...

检查是否已使用.hide隐藏控件(check to see if a control has been hidden with .hide)

我猜你不是故意这样做: 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 ...

如何隐藏段控件并展开UITableView?(How to hide segment control and expand UITableView?)

如果您使用autolayout,有两个选项 选项1:如果您不想在隐藏它后在视图中保留段控件,请为表视图底边添加约束,将其设置为常量0并将优先级设置为高(或者低于tableview和段控制的任何值) )。 现在,从superview中删除段控件。(参考这里 ) 选项2:为tableview底部交易添加约束并将其常量设置为某个高度,从而为分段控制提供足够的空间。 然后将布局约束与IBOutlet连接。 当你想要隐藏分段控件时,隐藏它并将布局约束的常量设置为0。 If you are using aut...

如何隐藏表单控件并只需要表单控件元素的值(how to hide form control and want only value of form control elements)

通过使用form-group元素的CSS display属性,您可以轻松地隐藏所需的元素。 这可以像下面这样实现: <div class="form-group" style="display:none;"> You can easily hide the required elements by using CSS display property for the form-group element. This can be achieved like below- <div class="...

我可以在NumericUpDown控件中隐藏值吗?(Can I hide Value in NumericUpDown control?)

注意:这取决于NumericUpDown的当前实现。 你需要做的是创建一个从NumericUpDown继承的新控件,使得: public partial class SpecialNumericUpDown : NumericUpDown { public SpecialNumericUpDown() { InitializeComponent(); } protected override void UpdateEditText() { ...

如何使用jquery显示/隐藏Fileuploader控件?(How to show/hide Fileuploader control using jquery?)

使用as,它将隐藏所有文件上传控件。 $('input[id$="files"]').hide(); Use as, it will hide all the file upload controls. $('input[id$="files"]').hide();

如果值为0,如何隐藏控件?(How to hide control if value is 0?)

如果查看Grid和Split布局的默认Visual Studio模板,您将找到一个值转换器的示例,它根据布尔值设置控件可见性。 代码显示在这里 public sealed class BooleanToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { ...

隐藏WebBrowser控件(Hide WebBrowser control)

尝试为IOleObject类型的实例(在您的情况下, mOleObject )调用DoVerb()并将OLEIVERB_HIDE作为动词传递。 更新: IHTMLElementRender接口可以更好地解决问题(请参阅将HTML文档捕获为图像 )。 I found another solution. I just make normal window and put the html control into the windown and hide it, which solves all th...

隐藏LostFocus上的控件(Hide control on LostFocus)

用以下代码替换注释的代码。 您的代码不起作用,因为MultiTriggers的工作方式与AND操作类似。 即如果两个文本框的IsFocused都设置为false,则仅取消选中该复选框。 <DataTrigger Binding="{Binding ElementName=TbxMinValRange, Path=IsFocused}" Value="False"> <Setter TargetName="chkAmountInValue" Property="IsChecked" Value="...

RDLC根据字段值显示/隐藏控件(RDLC Show/Hide control base on a field value)

尝试将您的可见性表达式更改为: =Sum(Fields!Interest.Value, "BasePayment")<=0 Try to change your visibility expression to this: =Sum(Fields!Interest.Value, "BasePayment")<=0

相关文章

更多

[Netty 1] 初识Netty

1. 简介 最早接触netty是在阅读Zookeeper源码的时候,后来看到Storm的消息传输层也由 ...

Netty源码分析

Netty提供异步的、事件驱动的网络应用程序框架和工具,用以快速开发高性能、高可靠性的网络服务器和客户 ...

Netty开发环境配置

最新版本的Netty 4.x和JDK 1.6及更高版本

Netty入门实例-时间服务器

Netty中服务器和客户端之间最大的和唯一的区别是使用了不同的Bootstrap和Channel实现

storm学习之Netty代替ZMQ

整理自 http://www.csdn.net/article/2014-08-04/2821018/ ...

Netty入门实例-编写服务器端程序

channelRead()处理程序方法实现如下

在Twitter,Netty 4 GC开销降为五分之一

原文:http://www.infoq.com/cn/news/2013/11/netty4-twit ...

Netty基于流的传输处理

​在TCP/IP的基于流的传输中,接收的数据被存储到套接字接收缓冲器中。不幸的是,基于流的传输的缓冲器 ...

Java Number类

Java Number类 一般地,当需要使用数字的时候,我们通常使用内置数据类型,如:byte、 ...

Netty入门实例-使用POJO代替ByteBuf

使用TIME协议的客户端和服务器示例,让它们使用POJO来代替原来的ByteBuf。

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本