示例#1
0
文件: MainWnd.cs 项目: hekinox/_QSend
        private void handleTransferHeader(object sender, ProgressChangedEventArgs e, int index)
        {
            if ((int)e.UserState == TransferStatus.COMPLETE)
            {
                TransferHeader header1 = (TransferHeader)(Util.deserialize(responseStream));

                // fie primeste un header pt permisiune fie primeste inapoi headerul cu tot cu permisiune

                if (header1.transferPermission == TransferPermission.REJECTED)
                {
                    return;
                }

                if (header1.transferPermission == TransferPermission.UNKNOWN)
                {
                    // to do: request permission for receiving this
                    header1.transferPermission = TransferPermission.ACCEPTED;

                    handshakeClient.sendData(header1.sourceIp, 2700, Util.serialize(header1));

                    return;
                }

                if (header1.transferPermission == TransferPermission.ACCEPTED)
                {
                    sendChunks(header1);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Creates a new Gatherer
        /// </summary>
        /// <param name="header">header structure transfered between handhshaking clients</param>
        public Gatherer(TransferHeader header)
        {
            this.header = header;
            inputStream = new FileStream(header.filePath, FileMode.Open);

            chunkSize    = 1 + header.fileSize / header.nOfStreams;
            _streamsRead = 0;
        }
示例#3
0
        /// <summary>
        /// Creates a new Gatherer
        /// </summary>
        /// <param name="header">header structure transfered between handhshaking clients</param>
        public Gatherer(TransferHeader header)
        {
            this.header = header;
            inputStream = new FileStream(header.filePath, FileMode.Open);

            chunkSize = 1 + header.fileSize / header.nOfStreams;
            _streamsRead = 0;
        }
示例#4
0
文件: MainWnd.cs 项目: hekinox/_QSend
        private void selectFileButton_Click(object sender, EventArgs e)
        {
            FileDialog   fileDialog = new OpenFileDialog();
            DialogResult result     = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                TransferHeader transferHeader = new TransferHeader(fileDialog.FileName, nOfStreams);

                handshakeClient.sendData(ipTextBox.Text, 2700, Util.serialize(transferHeader));
            }
        }
示例#5
0
文件: MainWnd.cs 项目: hekinox/_QSend
        private void sendChunks(TransferHeader header)
        {
            fileClients = new List <DataClient>();

            gatherer = new Gatherer(header);

            for (int i = 0; i < header.nOfStreams; i++)
            {
                fileClients.Add(new DataClient(i + 1, 2700 + i + 1, new FileStream("chunk" + i.ToString() + ".txt", FileMode.Create), handleTransferChunk, false));

                fileClients[i].sendData(header.sourceIp, 2700 + i + 1, gatherer.getNextChunk());
            }
        }
示例#6
0
文件: MainWnd.cs 项目: Apex95/_QSend
        private void sendChunks(TransferHeader header)
        {
            fileClients = new List<DataClient>();

            gatherer = new Gatherer(header);

            for (int i = 0; i < header.nOfStreams; i++)
            {
                fileClients.Add(new DataClient(i+1, 2700 + i + 1, new FileStream("chunk" + i.ToString() + ".txt", FileMode.Create), handleTransferChunk, false));

                fileClients[i].sendData(header.sourceIp, 2700 + i + 1, gatherer.getNextChunk());
            }
        }
示例#7
0
文件: MainWnd.cs 项目: Apex95/_QSend
        private void selectFileButton_Click(object sender, EventArgs e)
        {
            FileDialog fileDialog = new OpenFileDialog();
            DialogResult result = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                TransferHeader transferHeader = new TransferHeader(fileDialog.FileName, nOfStreams);

                handshakeClient.sendData(ipTextBox.Text, 2700, Util.serialize(transferHeader));
            }
        }