In the previous article I talked about the message push scenario and a simple Hello world based on the Netty implementation, to get a better understanding of the code in Hello World, today I'll explain some of the concepts and how it works in Netty. If you think this article is a bit boring, please read the "Android Netty-based message push solution Hello World"
Channeleventnetty is event-driven, which is what we have mentioned above, informing "relevant departments" of what happened. Therefore, it is not difficult to understand that in our own business code, there must be some processing related to these events. In the sample code, we deal with the event that is channelconnected. Later, we will also deal with more events. Channelpipeline pipeline, Transmission path. It controls the distribution and delivery of channelevent events. The event flows through the pipeline, which is handled with this channelpipeline. For example: development events. First give a design, then to b development. A flow chart, hoping to give you a more intuitive feeling. Pipe Flow diagram:
Channelhandler just said pipeline responsible for distributing the incident to the corresponding site, the site in Netty refers to Channelhandler. The incident to the Channelhandler here, is to be specifically processed, our sample code, the implementation is such a processing event "site", that is, your own business logic is generally starting from here.
Channelchannel, can tell you the status of the current channel, is together or closed. Gets the channel-related configuration information. Get pipeline and so on. Are some of the overall information. The channel is naturally produced by ChannelFactory. The type of channel implementation determines whether you are synchronizing or asynchronous (NIO). For example, we use Nioserversocketchannel in our sample. If you are interested, please continue to learn about the Netty "Android Netty-based message push scheme string receiving and sending (iii)"
The concept and working principle of Android Netty-based message push scheme (II.)