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

📄 tranbase.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Core.P2P.BlockingTransportor
{
    using Imps.Client.Core;
    using Imps.Client.Core.P2P.FileTransportor;
    using Imps.Client.Core.P2P.ICE;
    using Imps.Client.Utils;
    using System;
    using System.Net;
    using System.Threading;

    public abstract class TranBase : AbstractFileTransportor
    {
        protected readonly int BufferSize = 0x400;
        protected const int FailTimeMicroSec = 0x23c34600;
        protected PunchingResult result;
        protected const int SelectTimeout = 0x186a0;
        protected ILogicSocket socket;
        protected bool stoped;
        protected Thread tranThread;

        public TranBase(TransportingFile file, PunchingResult pr)
        {
            this.result = pr;
            base.targetFile = file;
            if (this.result is TcpConnectingResult)
            {
                this.BufferSize = 0x4000;
            }
        }

        public virtual void Init(IPEndPoint ep)
        {
            base.state = TransportState.Init;
            this.socket = this.result.CreateSocket(ep);
            if (this.result is TcpConnectingResult)
            {
                ClientLogger.WriteGeneral("使用Tcp方式进行文件传输");
            }
            else
            {
                ClientLogger.WriteGeneral("使用Udp方式进行文件传输");
            }
        }

        protected abstract void InternalTransport();
        public override void Start()
        {
            this.tranThread = new Thread(new ThreadStart(this.InternalTransport));
            this.tranThread.IsBackground = true;
            this.tranThread.Start();
            base.Start();
        }

        public override void Stop()
        {
            this.stoped = true;
            try
            {
                if (this.tranThread != null)
                {
                    this.tranThread.Join(0x3e8);
                }
                if (base.targetFile != null)
                {
                    base.targetFile.Close();
                }
            }
            catch
            {
            }
            finally
            {
                if (this.socket != null)
                {
                    try
                    {
                        this.socket.Close();
                    }
                    catch
                    {
                    }
                }
            }
            base.Stop();
        }

        public virtual long TranFileSize
        {
            get
            {
                return base.targetFile.FileSize;
            }
        }
    }
}

⌨️ 快捷键说明

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