public int StartGroupChat(string creator, List <string> usernames) { usernames.Sort(); List <Client> clients = new List <Client>(); int roomId = HashUsers(usernames); if (chatRoomAccepts.ContainsKey(roomId)) { Console.WriteLine("ChatRoom already exists! Removing..."); chatRoomAccepts.Remove(roomId); } Console.WriteLine($"roomId: {roomId}"); ChatRoomInfo info = new ChatRoomInfo(); chatRoomAccepts.Add(roomId, info); // Check for wrong usernames for (int i = 0; i < usernames.Count; i++) { Client cl = GetUserClient(usernames[i]); if (cl == null) { return(-1); } clients.Add(cl); } // Create roomChat and add creator to it info.roomId = roomId; info.creator = creator; info.clients = clients; AcceptChatRequest(roomId, creator); OnAskForChat(roomId, creator, usernames.ToList()); return(roomId); }
//-----------------------------------Remote methods----------------------------------- public bool JoinChatRoom(int roomId, ChatRoomInfo info) { chatRooms.Add(roomId, info); return(true); }