Upload() 공개 메소드

public Upload ( Socket connection, byte handshakeMsg, int handshakeMsgLength ) : void
connection System.Net.Sockets.Socket
handshakeMsg byte
handshakeMsgLength int
리턴 void
        public bool Handle(byte[] handshakeMsg, int length, Socket socket, object state)
        {
            socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
            var handler = new FileTransmitService();

            //handler.controller = _controller;
            //
            if (handshakeMsg[5] == 0x00)
            {
                handler.Upload(socket, handshakeMsg, length);
            }
            else
            {
                handler.Download(socket, handshakeMsg, length);
            }

            //轮询的方式关闭超时的连接
            //IList<FileTransmitService> handlersToClose = new List<FileTransmitService>();
            //lock (Handlers)
            //{
            //    Handlers.Add(handler);
            //    Logging.Debug("Adding Handler...");
            //    DateTime now = DateTime.Now;
            //    if (now - lastSweepTime > TimeSpan.FromSeconds(1))
            //    {
            //        lastSweepTime = now;
            //        foreach (var handlerNeedsToBeClosed in Handlers)
            //        {
            //            if (now - handlerNeedsToBeClosed.LastActivity > TimeSpan.FromSeconds(900))
            //            {
            //                handlersToClose.Add(handlerNeedsToBeClosed);
            //            }
            //        }
            //    }
            //}
            //foreach (var closingHandler in handlersToClose)
            //{
            //    Logging.Debug("Closing timed out TCP connection.");
            //    closingHandler.Close();
            //}
            return(true);
        }
        public bool Handle(byte[] handshakeMsg, int length, Socket socket, object state)
        {

            socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
            var handler = new FileTransmitService();
            //handler.controller = _controller;
            //
            if (handshakeMsg[5] == 0x00)
                handler.Upload(socket, handshakeMsg, length);
            else
                handler.Download(socket, handshakeMsg, length);

            //轮询的方式关闭超时的连接 
            //IList<FileTransmitService> handlersToClose = new List<FileTransmitService>();
            //lock (Handlers)
            //{
            //    Handlers.Add(handler);
            //    Logging.Debug("Adding Handler...");
            //    DateTime now = DateTime.Now;
            //    if (now - lastSweepTime > TimeSpan.FromSeconds(1))
            //    {
            //        lastSweepTime = now;
            //        foreach (var handlerNeedsToBeClosed in Handlers)
            //        {
            //            if (now - handlerNeedsToBeClosed.LastActivity > TimeSpan.FromSeconds(900))
            //            {
            //                handlersToClose.Add(handlerNeedsToBeClosed);
            //            }
            //        }
            //    }
            //}
            //foreach (var closingHandler in handlersToClose)
            //{
            //    Logging.Debug("Closing timed out TCP connection.");
            //    closingHandler.Close();
            //}
            return true;
        }