⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipconnectionimp.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
                return this._Context;
            }
        }

        public virtual long CurrentAdapterSpeed
        {
            get
            {
                NetworkInterface adapterByIP = IMPSNetworkChange.Instance.GetAdapterByIP(this.LocalEndPoint);
                if (adapterByIP != null)
                {
                    return (adapterByIP.get_Speed() / ((long) 0x400));
                }
                return (long) 0;
            }
        }

        public ISipConnection InnerSipConnection
        {
            get
            {
                return this.conBase;
            }
        }

        public IPEndPoint LocalEndPoint
        {
            get
            {
                if (this.conBase != null)
                {
                    return this.conBase.LocalEndPoint;
                }
                return null;
            }
        }

        public IPEndPoint RemoteEndPoint
        {
            get
            {
                if (this.conBase != null)
                {
                    return this.conBase.RemoteEndPoint;
                }
                return null;
            }
        }

        public ConnectionState State
        {
            get
            {
                if (this.conBase != null)
                {
                    return this.conBase.State;
                }
                return this._State;
            }
            set
            {
                if (value != ((ConnectionState) this._State))
                {
                    StateChangedEventArgs argument = new StateChangedEventArgs(this._State, value);
                    this._State = value;
                    if (this._State == 11)
                    {
                        this.RaiseStateChanged(argument);
                    }
                }
            }
        }

        [CompilerGenerated]
        private sealed class <GetConnectionTypes>d__f : IEnumerable<ConnectionInfo>, IEnumerable, IEnumerator<ConnectionInfo>, IEnumerator, IDisposable
        {
            public ConnectionInfo <_info>5__11;
            private int <>1__state;
            private ConnectionInfo <>2__current;
            public SipConnectionImp <>4__this;
            public List<ConnectionInfo>.Enumerator <>7__wrap12;
            public ConnectionInfo <info>5__10;

            [DebuggerHidden]
            public <GetConnectionTypes>d__f(int <>1__state)
            {
                this.<>1__state = <>1__state;
            }

            private bool MoveNext()
            {
                bool flag;
                try
                {
                    switch (this.<>1__state)
                    {
                        case 0:
                            this.<>1__state = -1;
                            this.<>7__wrap12 = this.<>4__this.ConnectionTypes.GetEnumerator();
                            this.<>1__state = 1;
                            goto Label_0077;

                        case 2:
                            this.<>1__state = 1;
                            goto Label_0077;

                        case 3:
                            goto Label_00B5;

                        default:
                            goto Label_00D2;
                    }
                Label_0048:
                    this.<info>5__10 = this.<>7__wrap12.get_Current();
                    this.<>2__current = this.<info>5__10;
                    this.<>1__state = 2;
                    return true;
                Label_0077:
                    if (this.<>7__wrap12.MoveNext())
                    {
                        goto Label_0048;
                    }
                    this.<>1__state = -1;
                    this.<>7__wrap12.Dispose();
                    while ((this.<_info>5__11 = this.<>4__this.RaiseReadNextConnectionInfo()) != null)
                    {
                        this.<>2__current = this.<_info>5__11;
                        this.<>1__state = 3;
                        return true;
                    Label_00B5:
                        this.<>1__state = -1;
                    }
                Label_00D2:
                    flag = false;
                }
                fault
                {
                    this.Dispose();
                }
                return flag;
            }

            [DebuggerHidden]
            IEnumerator<ConnectionInfo> IEnumerable<ConnectionInfo>.GetEnumerator()
            {
                if (Interlocked.CompareExchange(ref this.<>1__state, 0, -2) == -2)
                {
                    return this;
                }
                SipConnectionImp.<GetConnectionTypes>d__f _f = new SipConnectionImp.<GetConnectionTypes>d__f(0);
                _f.<>4__this = this.<>4__this;
                return _f;
            }

            [DebuggerHidden]
            IEnumerator IEnumerable.GetEnumerator()
            {
                return this.System.Collections.Generic.IEnumerable<Imps.Client.CommLayer.ConnectionInfo>.GetEnumerator();
            }

            [DebuggerHidden]
            void IEnumerator.Reset()
            {
                throw new NotSupportedException();
            }

            void IDisposable.Dispose()
            {
                switch (this.<>1__state)
                {
                    case 1:
                    case 2:
                        break;

                    default:
                        return;
                        try
                        {
                        }
                        finally
                        {
                            this.<>1__state = -1;
                            this.<>7__wrap12.Dispose();
                        }
                        break;
                }
            }

            ConnectionInfo IEnumerator<ConnectionInfo>.Current
            {
                [DebuggerHidden]
                get
                {
                    return this.<>2__current;
                }
            }

            object IEnumerator.Current
            {
                [DebuggerHidden]
                get
                {
                    return this.<>2__current;
                }
            }
        }

        private delegate void ConnectResultDelegate(FailedEventArgs args);

        private class TryConnectionProc
        {
            private ISipConnection _connection;
            private object Context;
            private ConnectionInfo Info;

            public event EventHandler<FailedEventArgs> Failed;

            public event EventHandler<StateChangedEventArgs> StateChanged;

            public TryConnectionProc(ConnectionInfo info, object context)
            {
                this.Info = info;
                this.Context = context;
            }

            private void conBase_ConnectFailed(object sender, FailedEventArgs e)
            {
                this.RaiseFailed(e);
            }

            private void conBase_StateChanged(object sender, StateChangedEventArgs e)
            {
                ISipConnection connection = sender as ISipConnection;
                if (connection.State == ConnectionState.Connected)
                {
                    connection.ConnectFailed -= new EventHandler<FailedEventArgs>(this, (IntPtr) this.conBase_ConnectFailed);
                    connection.StateChanged -= new EventHandler<StateChangedEventArgs>(this, (IntPtr) this.conBase_StateChanged);
                }
                this.RaiseStateChanged(e);
            }

            public void Connect(string host, int port, out ISipConnection sipConn)
            {
                try
                {
                    sipConn = Activator.CreateInstance(this.Info.Type, new object[] { this.Context, this.Info.Option }) as ISipConnection;
                    sipConn.ConnectFailed += new EventHandler<FailedEventArgs>(this, (IntPtr) this.conBase_ConnectFailed);
                    sipConn.StateChanged += new EventHandler<StateChangedEventArgs>(this, (IntPtr) this.conBase_StateChanged);
                    sipConn.Connect(host, port);
                }
                catch (Exception exception)
                {
                    sipConn = null;
                    this.RaiseFailed(new FailedEventArgs(exception, "未能与服务器建立连接"));
                }
            }

            private void RaiseFailed(FailedEventArgs args)
            {
                EventHandler<FailedEventArgs> failed = this.Failed;
                if (failed != null)
                {
                    failed.Invoke(this, args);
                }
            }

            private void RaiseStateChanged(StateChangedEventArgs e)
            {
                EventHandler<StateChangedEventArgs> stateChanged = this.StateChanged;
                if (stateChanged != null)
                {
                    stateChanged.Invoke(this, e);
                }
            }

            public ISipConnection Connection
            {
                get
                {
                    return this._connection;
                }
            }
        }

        private enum TryNextType
        {
            TryAll,
            TryOnlyHttp,
            NotTry
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -