public ConnectionConfigInternal(ConnectionConfig config)
 {
     if (config == null)
     {
         throw new NullReferenceException("config is not defined");
     }
     m_Ptr = InternalCreate();
     if (!SetPacketSize(config.PacketSize))
     {
         throw new ArgumentOutOfRangeException("PacketSize is too small");
     }
     this.FragmentSize          = config.FragmentSize;
     this.ResendTimeout         = config.ResendTimeout;
     this.DisconnectTimeout     = config.DisconnectTimeout;
     this.ConnectTimeout        = config.ConnectTimeout;
     this.MinUpdateTimeout      = config.MinUpdateTimeout;
     this.PingTimeout           = config.PingTimeout;
     this.ReducedPingTimeout    = config.ReducedPingTimeout;
     this.AllCostTimeout        = config.AllCostTimeout;
     this.NetworkDropThreshold  = config.NetworkDropThreshold;
     this.OverflowDropThreshold = config.OverflowDropThreshold;
     this.MaxConnectionAttempt  = config.MaxConnectionAttempt;
     this.AckDelay  = config.AckDelay;
     this.SendDelay = config.SendDelay;
     this.MaxCombinedReliableMessageSize  = config.MaxCombinedReliableMessageSize;
     this.MaxCombinedReliableMessageCount = config.MaxCombinedReliableMessageCount;
     this.MaxSentMessageQueueSize         = config.MaxSentMessageQueueSize;
     this.AcksType = (byte)config.AcksType;
     this.UsePlatformSpecificProtocols  = config.UsePlatformSpecificProtocols;
     this.InitialBandwidth              = config.InitialBandwidth;
     this.BandwidthPeakFactor           = config.BandwidthPeakFactor;
     this.WebSocketReceiveBufferMaxSize = config.WebSocketReceiveBufferMaxSize;
     this.UdpSocketReceiveBufferMaxSize = config.UdpSocketReceiveBufferMaxSize;
     if (config.SSLCertFilePath != null)
     {
         int len = SetSSLCertFilePath(config.SSLCertFilePath);
         if (len != 0)
         {
             throw new ArgumentOutOfRangeException("SSLCertFilePath cannot be > than " + len);
         }
     }
     if (config.SSLPrivateKeyFilePath != null)
     {
         int len = SetSSLPrivateKeyFilePath(config.SSLPrivateKeyFilePath);
         if (len != 0)
         {
             throw new ArgumentOutOfRangeException("SSLPrivateKeyFilePath cannot be > than " + len);
         }
     }
     if (config.SSLCAFilePath != null)
     {
         int len = SetSSLCAFilePath(config.SSLCAFilePath);
         if (len != 0)
         {
             throw new ArgumentOutOfRangeException("SSLCAFilePath cannot be > than " + len);
         }
     }
     for (byte i = 0; i < config.ChannelCount; ++i)
     {
         AddChannel((byte)config.GetChannel(i));
     }
     for (byte i = 0; i < config.SharedOrderChannelCount; ++i)
     {
         IList <byte> sharedOrderChannelsList  = config.GetSharedOrderChannels(i);
         byte[]       sharedOrderChannelsArray = new byte[sharedOrderChannelsList.Count];
         sharedOrderChannelsList.CopyTo(sharedOrderChannelsArray, 0);
         MakeChannelsSharedOrder(sharedOrderChannelsArray);
     }
 }
Exemple #2
0
        public ConnectionConfigInternal(ConnectionConfig config)
        {
            bool flag = config == null;

            if (flag)
            {
                throw new NullReferenceException("config is not defined");
            }
            this.m_Ptr = ConnectionConfigInternal.InternalCreate();
            bool flag2 = !this.SetPacketSize(config.PacketSize);

            if (flag2)
            {
                throw new ArgumentOutOfRangeException("PacketSize is too small");
            }
            this.FragmentSize          = config.FragmentSize;
            this.ResendTimeout         = config.ResendTimeout;
            this.DisconnectTimeout     = config.DisconnectTimeout;
            this.ConnectTimeout        = config.ConnectTimeout;
            this.MinUpdateTimeout      = config.MinUpdateTimeout;
            this.PingTimeout           = config.PingTimeout;
            this.ReducedPingTimeout    = config.ReducedPingTimeout;
            this.AllCostTimeout        = config.AllCostTimeout;
            this.NetworkDropThreshold  = config.NetworkDropThreshold;
            this.OverflowDropThreshold = config.OverflowDropThreshold;
            this.MaxConnectionAttempt  = config.MaxConnectionAttempt;
            this.AckDelay  = config.AckDelay;
            this.SendDelay = config.SendDelay;
            this.MaxCombinedReliableMessageSize  = config.MaxCombinedReliableMessageSize;
            this.MaxCombinedReliableMessageCount = config.MaxCombinedReliableMessageCount;
            this.MaxSentMessageQueueSize         = config.MaxSentMessageQueueSize;
            this.AcksType = (byte)config.AcksType;
            this.UsePlatformSpecificProtocols  = config.UsePlatformSpecificProtocols;
            this.InitialBandwidth              = config.InitialBandwidth;
            this.BandwidthPeakFactor           = config.BandwidthPeakFactor;
            this.WebSocketReceiveBufferMaxSize = config.WebSocketReceiveBufferMaxSize;
            this.UdpSocketReceiveBufferMaxSize = config.UdpSocketReceiveBufferMaxSize;
            bool flag3 = config.SSLCertFilePath != null;

            if (flag3)
            {
                int  num   = this.SetSSLCertFilePath(config.SSLCertFilePath);
                bool flag4 = num != 0;
                if (flag4)
                {
                    throw new ArgumentOutOfRangeException("SSLCertFilePath cannot be > than " + num.ToString());
                }
            }
            bool flag5 = config.SSLPrivateKeyFilePath != null;

            if (flag5)
            {
                int  num2  = this.SetSSLPrivateKeyFilePath(config.SSLPrivateKeyFilePath);
                bool flag6 = num2 != 0;
                if (flag6)
                {
                    throw new ArgumentOutOfRangeException("SSLPrivateKeyFilePath cannot be > than " + num2.ToString());
                }
            }
            bool flag7 = config.SSLCAFilePath != null;

            if (flag7)
            {
                int  num3  = this.SetSSLCAFilePath(config.SSLCAFilePath);
                bool flag8 = num3 != 0;
                if (flag8)
                {
                    throw new ArgumentOutOfRangeException("SSLCAFilePath cannot be > than " + num3.ToString());
                }
            }
            byte b = 0;

            while ((int)b < config.ChannelCount)
            {
                this.AddChannel((int)((byte)config.GetChannel(b)));
                b += 1;
            }
            byte b2 = 0;

            while ((int)b2 < config.SharedOrderChannelCount)
            {
                IList <byte> sharedOrderChannels = config.GetSharedOrderChannels(b2);
                byte[]       array = new byte[sharedOrderChannels.Count];
                sharedOrderChannels.CopyTo(array, 0);
                this.MakeChannelsSharedOrder(array);
                b2 += 1;
            }
        }