/// <summary> /// Create a new room, only happens if the room does not already exists. /// </summary> /// <param name="clientThread"></param> /// <param name="currentRoom"></param> /// <param name="name"></param> public void CreateRoom(ClientThread clientThread, Room currentRoom, string name) { if (!RoomExists(name)) { currentRoom.RemoveClient(clientThread); Room room = new Room(this, name); room.AddClient(clientThread); rooms.Add(room); clientThread.JoinRoom(room); } }
/// <summary> /// Adds a client to this room. /// </summary> /// <param name="clientThread"></param> public void AddClient(ClientThread clientThread) { clientThread.JoinRoom(this); clients.Add(clientThread); SendToAllClientsInRoom(new Message(MessageTypes.JoinRoom, JsonConvert.SerializeObject(new RoomModel(this.Name, this.clients.Count)))); SendToAllClientsInRoom(new Message(MessageTypes.Inform, JsonConvert.SerializeObject(new GuessModel(clientThread.Name + " joined the room")))); if (this.Name.ToLower() != "hub") { if (clients.Count == 1) { this.MakeHost(clientThread); } } }