in the previous article I described the scenario for message push and a simple Hello world based on the Netty implementation. To better understand the code in Hello World, let me explain some of the concepts and working principles of Netty today, assuming you think this article is a bit boring. Please read the Hello World(i) of Android Netty-based message push scheme first
channeleventNetty is event-driven, as we mentioned above. What happened. The "relevant department" is notified.
So. Not hard to understand. In our own business code, there must be processing related to these events. In the example code, we deal with the event that is channelconnected.
later. We will also deal with many other events.
ChannelpipelinePipelines, transmission pathways. It controls the distribution and delivery of channelevent events. The event flows through the pipeline. This is the channelpipeline to deal with.
Analogy: Development events. Give a design first. And then to B development. A flow chart. Hope to give you a more intuitive feeling.
pipe Flow diagram :
ChannelhandlerJust said pipeline is responsible for distributing the incident to the corresponding website. Website in Netty refers to Channelhandler. The incident to Channelhandler here, is to be dealt with in detail, in our example code, the implementation of this is a "site" to deal with the event, that is, your own business logic is generally started 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 implementation type of the channel. Determines whether your channel is synchronous or asynchronous (NIO). For example, Nioserversocketchannel is used in our example.
If you are interested, please continue to understand the Netty"Android Netty-based message push scheme string for receiving and sending (iii)"
The concept and working principle of Android Netty-based message push scheme (II.)