Implementation features
Add different Tlswebsocketlistener to pipeline based on different listener (TcpListener, Tlstcplistener, Websocketlistener, handler) of the User Configuration
Implementation steps
1, according to listener different, generate different handler
2, add to pipeline, let it for each client service
Class diagram
As can be seen for different listener will have corresponding type of Channelinitializer to initialize transport Channel, understand this, it is good to understand.
1、ChannelInitializerFactory是AbstractChannelInitializer的一个工厂类,针对不同的Listener,可以生成不同的ChannelInitializer。2、ChannelInitializerFactory去判断Listener类型,去创建对应的AbstractChannelInitializer,TlsTcpChannelInitializer、WebsocketChannelInitializer、TlsWebsocketChannelInitializer都是AbstractChannelInitializer的实现类。3、通过实现AbstractChannelInitializer的initTransportChannel,将对应的Handler加入到pipeline中。4、若是TcpListener、WebsocketListener,则将NoSslHandler加入到pipeline中,来阻止ssl连接
5、SslContextStore是持有Tls和SslContext的映射关系的一个仓库,加单点说就是key为Tls,value为SslContext的map的封装类。6、SslFactory通过Channel和Tls创建SslHandler,并设置SSLEngine,以达到SSL认证,具体的认证过程以及处理都是属于标准ssl处理流程,使用netty的SslHandler去完成,什么是双向认证、单向认证等概念,就需要大家自行研究,不属于本博文的内容。
With this we can know that HIVEMQ is actually different from the type of listener, creating different abstractchannelinitializer, implementing the Inittransportchannel method, To add a sslhandler/nosslhandlermqtt to the pipeline group: 221405150
MQTT---HIVEMQ source detailed (vii) NETTY-SSL/NOSSL