public void Run() { _requests.SendStringMessage(_client, ClientOptions.LEAVE_GROUP_CHAT.ToString()); try { AllGroupChat allGroupChat = (AllGroupChat)_requests.GetModelMessage(_client); PrintAllGroups(allGroupChat); if (allGroupChat.GroupsName.Count > 0) { _system.Write("enter group name"); string userResponse = _system.ReadString(); if (CheckGroupName(userResponse, allGroupChat)) { _requests.SendStringMessage(_client, userResponse); _system.Write("you leave group"); } else { _requests.SendStringMessage(_client, "0"); _system.Write("the group not exist"); } } else { _requests.SendStringMessage(_client, "0"); _system.Write("you dont have groups to leave"); } } catch (Exception e) { } }
public void Run() { try { _requests.SendStringMessage(_client, ClientOptions.MANAGER_SETTINGS.ToString()); AllGroupChat allGroupChat = (AllGroupChat)_requests.GetModelMessage(_client); PrintAllGroups(allGroupChat); if (allGroupChat.GroupsName.Count > 0) { _system.Write("enter group name"); string userResponse = _system.ReadString(); if (CheckGroupName(userResponse, allGroupChat)) { _requests.SendStringMessage(_client, userResponse); GroupChat groupChat = (GroupChat)_requests.GetModelMessage(_client); Participants participants = (Participants)_requests.GetModelMessage(_client); _system.Write("enter names you want to remove from group, when end enter o"); PrintParticipants(groupChat.Participants); List <Guid> usersToRemove = GetAllParticipants(groupChat.Participants); _system.Write("enter names you want to add to group, when end enter o"); PrintParticipants(participants.AllParticipants); List <Guid> usersToAdd = GetAllParticipants(participants.AllParticipants); usersToAdd.RemoveAll(u => CheckIfParticipantsExist(u, groupChat.Participants) == true); _system.Write("enter names you want to add as mangers, when end enter o"); List <Guid> usersToAddAsMangers = GetAllParticipants(groupChat.Participants); usersToAddAsMangers.RemoveAll(u => CheckIfParticipantsExist(u, usersToRemove) == true); ChangeGroup(groupChat, usersToRemove, usersToAdd, usersToAddAsMangers); _requests.SendModelMessage(_client, groupChat); } else { _requests.SendStringMessage(_client, "0"); _system.Write("the group not exist"); } } else { _requests.SendStringMessage(_client, "0"); _system.Write("you dont have any group that you managment"); } } catch (Exception) { } }
public void Run() { _requests.SendStringMessage(_client, ClientOptions.GROUP_CHAT.ToString()); endConnection = false; try { AllGroupChat allGroupChat = (AllGroupChat)_requests.GetModelMessage(_client); PrintAllGroups(allGroupChat); if (allGroupChat.GroupsName.Count > 0) { _system.Write("enter group name"); string userResponse = _system.ReadString(); if (CheckGroupName(userResponse, allGroupChat)) { _requests.SendStringMessage(_client, userResponse); ListenToServer(); while (!endConnection) { _system.Write("enter message, if you wand to exist chat enter: 0"); string message = _system.ReadString(); if (message == "0") { endConnection = true; } _requests.SendStringMessage(_client, message); } } else { _requests.SendStringMessage(_client, "0"); _system.Write("the group not exist"); } } else { _requests.SendStringMessage(_client, "0"); _system.Write("you dont have group to enter"); } } catch (Exception e) { } }
private bool CheckGroupName(string userResponse, AllGroupChat allGroupChat) { return(GruopUtils.CheckGroupName(userResponse, allGroupChat)); }
private void PrintAllGroups(AllGroupChat allGroupChat) { GruopUtils.PrintString(allGroupChat.GroupsName, _system); }
public static void SendAllGroupChat(TcpClient client, IRequests requests, List <string> grouspName) { AllGroupChat allGroupChat = new AllGroupChat(grouspName); requests.SendModelMessage(client, allGroupChat); }
public static bool CheckGroupName(string userResponse, AllGroupChat allGroupChat) { return(allGroupChat.GroupsName.Contains(userResponse)); }