Example #1
0
        private void btnDownloadFile_Click(object sender, EventArgs e)
        {
            DownloadFileCo co = new DownloadFileCo();

            co.Url      = txtUrl.Text;
            co.SavePath = txtSavePath.Text;

            int port = int.Parse(cboClient.SelectedItem.ToString());

            clientMap[port].Send(co);
        }
        private void dealDownloadFile(Socket socket, DownloadFileCo co)
        {
            DownloadFileServer server = new DownloadFileServer();

            string uuid = logReqMsg(socket, "URL:" + co.Url + ", savePath:" + co.SavePath);

            server.downloadFile(co.Url, co.SavePath,
                                delegate(DownloadFileCro cro)
            {
                logResMsg(socket, "isSuccess:" + cro.IsSuccess + ", savePath:" + cro.LocalPath + ", Message:" + cro.Message, uuid);
                // 异步调用结束
                AsyncServerSocket.getInstance().Send(socket, cro);
                server = null;
            });
        }
Example #3
0
        private void dealDownloadFile(IWebSocketConnection socket, DownloadFileCo co)
        {
            DownloadFileServer server = new DownloadFileServer();


            logReqMsg(socket, "URL:" + co.Url + ", savePath:" + co.SavePath, co.Uuid);

            server.downloadFile(co.Url, co.SavePath,
                                delegate(DownloadFileCro cro)
            {
                cro.Uuid = co.Uuid;

                logResMsg("isSuccess:" + cro.IsSuccess + ", savePath:" + cro.LocalPath + ", Message:" + cro.Message, co.Uuid);
                // 异步调用结束
                socket.Send(CommunicateUtils.communicateVoToStr(cro));
                server = null;
            });
        }