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 HelloWorld"
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.
Channelpipelinepipelines, transmission pathways. 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 the event distribution 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, which can tell you the status of the current channel, together or off. 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.
in the next article I will introduce Netty string reception.
The concept and working principle of Android Netty-based message push scheme (ii)