Exemplo n.º 1
0
 public void Loop(IRawServer rawServer)
 {
     this.rawServer     = rawServer;
     this.taskDelegates = new List <TaskDelegate>();
     taskDelegates.Add(Raw);
     rawServer.AddTask(Raw, 0.1, string.Empty);
 }
Exemplo n.º 2
0
        public void sl(IRawServer rawServer, DummyEncrypter encrypter, int port)
        {
            rawServer.Bind(port, "127.0.0.1", false);
            this.handler = encrypter;
            Thread t = new Thread(Go);

            t.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="rawServer">服务器</param>
        /// <param name="socket">套接字</param>
        /// <param name="handler">封装连接管理类</param>
        public SingleSocket(IRawServer rawServer, Socket socket, IEncrypter handler)
        {
            this.rawServer = rawServer;
            this.Socket    = socket;
            this.Handler   = handler;

            this.buffer      = new LinkedList <byte[]>();
            this.lastHit     = DateTime.Now;
            this.isConnected = false;
        }
Exemplo n.º 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="connecter">连接管理类</param>
 /// <param name="rawServer">服务器类</param>
 /// <param name="myID">本地下载工具ID号</param>
 /// <param name="maxLength">最大请求子片断长度</param>
 /// <param name="scheduleFunction">计划函数</param>
 /// <param name="keepAliveDelay">发送keep alive信息的时间间隔</param>
 /// <param name="downloadID">对方下载工具ID号</param>
 /// <param name="maxInitiate">最大连接数</param>
 public Encrypter(IConnecter connecter, IRawServer rawServer, byte[] myID, int maxLength,
                  SchedulerDelegate scheduleFunction, double keepAliveDelay, byte[] downloadID, int maxInitiate)
 {
     this.rawServer        = rawServer;
     this.Connecter        = connecter;
     this.MyID             = myID;
     this.maxLength        = maxLength;
     this.scheduleFunction = scheduleFunction;
     this.keepAliveDelay   = keepAliveDelay;
     this.DownloadID       = downloadID;
     this.maxInitiate      = maxInitiate;
     this.connections      = new Dictionary <ISingleSocket, IEncryptedConnection>();
     scheduleFunction(SendKeepAlives, keepAliveDelay, "Send keep alives");
 }