好吧所以我正在尝试使用Netty 4.0.19(顺便说一下这很棒)并且有一个连接工作正常,但是一旦有多个连接,就会出现一个错误,即处理程序不是共享处理程序而且不能有多个项目。
这是我的Handler类: ChannelManager.java
我在想,也许每个连接都需要自己的处理程序,但后来我不确定如何在当前环境中实现它。 有什么建议或想法吗?
编辑:我不知道如何在谷歌上问这个问题...所以,如果这个问题已经存在,请原谅。
我认为它与代码中的第59行有关。 我看到一些ChannelInitializer的使用,但我不知道如何使用它。
Alright so I am experimenting with Netty 4.0.19 (which is great by the way) and having one connection works fine, but once there are multiple connections there is an error that the handler is not a shared handler and cannot have multiple items.
This is my Handler class: ChannelManager.java
I was thinking, maybe every connection needs its own handler, but then I'm not sure how I will implement that in my current environment. Any suggestions or ideas?
EDIT : I wasn't sure how to ask this question on google... so excuse me if this question already exists.
I think it has something to do with line 59 in the code. I saw some use of a ChannelInitializer but I don't know how to use that.
最满意答案
如果您的处理程序可以在多个客户端之间共享,则需要使用以下方法对该类进行注释:
@ChannelHandler.Sharableif your handler can be shared between multiple clients you need to annotate the class with:
@ChannelHandler.Sharable更多推荐
发布评论