示例#1
0
 public void SetConfig(IWebSocketClientConfig config)
 {
     if (config is DotNettyClientConfig webSocketClientConfig)
     {
         if (webSocketClientConfig.Verification(out List <string> messages))
         {
             Config = webSocketClientConfig;
             if (webSocketClientConfig.UseLibuv)
             {
                 _eventLoopGroup = new EventLoopGroup();
             }
             else
             {
                 _eventLoopGroup = new MultithreadEventLoopGroup();
             }
             if (webSocketClientConfig.SSLConfig != null && webSocketClientConfig.SSLConfig.UseSSL)
             {
                 _x509Certificate2 = new X509Certificate2(webSocketClientConfig.SSLConfig.PfxFilePath, webSocketClientConfig.SSLConfig.PfxPassword);
                 _targetHost       = _x509Certificate2.GetNameInfo(X509NameType.DnsName, false);
             }
         }
         else
         {
             throw new MateralWebSocketClientException(string.Join(",", messages));
         }
     }
     else
     {
         throw new MateralWebSocketClientException("Config类型必须派生于DotNettyClientConfig");
     }
 }
示例#2
0
 public void SetConfig(IWebSocketClientConfig config)
 {
     if (config is WebSocketClientConfig webSocketClientConfig)
     {
         if (webSocketClientConfig.Verification(out List <string> messages))
         {
             Config = webSocketClientConfig;
         }
         else
         {
             throw new MateralWebSocketClientException(string.Join(",", messages));
         }
     }
     else
     {
         throw new MateralWebSocketClientException("Config类型必须派生于WebSocketClientConfig");
     }
 }