Example #1
0
        private static void OfferFile(SentFile fileToSend, TcpClient clientSocket, Chat currentChat)
        {
            bool waitingAnswer = true;

            while (waitingAnswer)
            {
                var userResponse = protocol.RecieveData(clientSocket);
                if (userResponse.Equals("si"))
                {
                    StartQueue();
                    SendToQueue("Un usuario acepto un archivo");
                    waitingAnswer = false;
                    protocol.SendData("1", clientSocket);
                    FileStream file        = new FileStream(fileToSend.FileServerPath, FileMode.Open, FileAccess.Read);
                    int        noOfPackets = protocol.CalculateNoOfPackets(file);

                    protocol.SendData("" + noOfPackets, clientSocket);
                    protocol.SendData(fileToSend.FileName, clientSocket);
                    protocol.SendFile(file, clientSocket);
                }
                else
                {
                    if (userResponse.Equals("no"))
                    {
                        waitingAnswer = false;
                        protocol.SendData("2", clientSocket);
                        StartQueue();
                        SendToQueue("Un usuario rechazo un archivo");
                    }
                    else
                    {
                        protocol.SendData("3", clientSocket);
                    }
                }
            }
        }
Example #2
0
        private static void DeleteServerFile(string path, Chat currentChat)
        {
            SentFile file = GetFile(path, currentChat);

            currentChat.Files.Remove(file);
        }