private void handleCommand(string cmd) { try { string[] commands = cmd.Split('#'); int countCommands = commands.Length; for (int i = 0; i < countCommands; i++) { string currentCommand = commands[i]; if (string.IsNullOrEmpty(currentCommand)) { continue; } if (!AuthSuccess) { if (currentCommand.Contains("setname")) { if (setName(currentCommand.Split('|')[1])) { Send("#setnamesuccess"); } else { Send("#setnamefailed"); } } continue; } if (currentCommand.Contains("yy")) { string id = currentCommand.Split('|')[1]; Server.FileD file = Server.GetFileByID(int.Parse(id)); if (file.ID == 0) { SendMessage("Ошибка при передаче файла...", "1"); continue; } Send(file.fileBuffer); Server.Files.Remove(file); } if (currentCommand.Contains("message")) { string[] Arguments = currentCommand.Split('|'); Server.SendGlobalMessage($"[{_userName}]: {Arguments[1]}", "Black"); continue; }//sENDfile //... if (currentCommand.Contains("endsession")) { Server.EndUser(this); return; } if (currentCommand.Contains("sendfileto")) { string[] Arguments = currentCommand.Split('|'); string TargetName = Arguments[1]; int FileSize = int.Parse(Arguments[2]); string FileName = Arguments[3]; byte[] fileBuffer = new byte[FileSize]; _userHandle.Receive(fileBuffer); User targetUser = Server.GetUser(TargetName); if (targetUser == null) { SendMessage($"Пользователь {FileName} не найден!", "Black"); continue; } Server.FileD newFile = new Server.FileD() { ID = Server.Files.Count + 1, FileName = FileName, From = Username, fileBuffer = fileBuffer, FileSize = fileBuffer.Length }; Server.Files.Add(newFile); targetUser.SendFile(newFile, targetUser); } if (currentCommand.Contains("private")) { string[] Arguments = currentCommand.Split('|'); string TargetName = Arguments[1]; string Content = Decrypt(Arguments[2].Trim()); User targetUser = Server.GetUser(TargetName); if (targetUser == null) { SendMessage($"Пользователь {TargetName} не найден!", "Red"); continue; } Console.WriteLine($"-[Отправлено][{TargetName}]: {Content}"); Console.WriteLine($"-[Получено][{Username}]: {Content}"); Content = Encrypt(Content); PrivateMessage($"-[Отправлено][{TargetName}]:", $" {Content}", "Black"); targetUser.PrivateMessage($"-[Получено][{Username}]:", $" {Content}", "Black"); continue; } } } catch (Exception exp) { Console.WriteLine("Error with handleCommand: " + exp.Message); } }