Example #1
0
        private void ShowFiles()
        {
            FileSearchAndRegistrationMessageProvider fsrmp = new FileSearchAndRegistrationMessageProvider(SocketResourcesManager.srm.ProvideBuffer());
            OutputMessage om = fsrmp.ProvideFileSearchByKeywordRequestMessage(txtSearch.Text);

            ClientCommunicationCenter.commCenter.SendMessageToServer(om);
        }
        private void SendHash(int chunkId, byte[] hash)
        {
            FileSearchAndRegistrationMessageProvider frmp = new FileSearchAndRegistrationMessageProvider(SocketResourcesManager.srm.ProvideBuffer());
            OutputMessage om = frmp.ProvideResponseChunksMessage(fd.FileId, chunkId, hash);

            ClientCommunicationCenter.commCenter.SendMessageToServer(om);
        }
        private void SendFileRegistrationRequest()
        {
            Debug.WriteLine("Sending request for registration");
            FileSearchAndRegistrationMessageProvider frmp = new FileSearchAndRegistrationMessageProvider(SocketResourcesManager.srm.ProvideBuffer());
            OutputMessage om = frmp.ProvideRequestFileRegistration(fd.FileName + "." + fd.FileExtension, fd.FileSize);

            ClientCommunicationCenter.commCenter.SendMessageToServer(om);
        }
        private void HandleResponseConnect(S2CMessageReader mr)
        {
            Debug.WriteLine("Connected!");
            FileTransferCenter.ftc.ncm.ConnectionWithServerEstablished();
            FileTransferCenter.ftc.ts.AllLocalFilesStartTransfer();

            string delFiles = "";

            foreach (FileDescription fd in MasterFileManager.mfm.DeletedFiles.Values)
            {
                FileSearchAndRegistrationMessageProvider fsmp = new FileSearchAndRegistrationMessageProvider(SocketResourcesManager.srm.ProvideBuffer());
                OutputMessage msg = fsmp.ProvideFileDeletedMessage(fd.FileId);
                ClientCommunicationCenter.commCenter.SendMessageToServer(msg);
                delFiles += fd.FileName + "." + fd.FileExtension + ",";
            }

            if (delFiles != "")
            {
                delFiles.TrimEnd(',');
                MessageBox.Show("System has detected that some files: " + delFiles + Environment.NewLine + " have been deleted from hard drive!");
            }
            initAll = true;
        }