private bool JoinRoom(int roomID, string password, out Room room)
 {
     room = null;
     if(server.lobby.rooms.ContainsKey(roomID) && server.lobby.rooms[roomID].users.Count < 4)
     {
         room = server.lobby.rooms[roomID];
         if(room.isEncrypted)
         {
             if(room.password == password)
             {
                 user.MoveToUserGroup(room);
                 RoomUpdateBroadcast(room);
                 return true;
             }
             else
             {
                 room = null;
                 return false;
             }
         }
         else
         {
             user.MoveToUserGroup(room);
             RoomUpdateBroadcast(room);
             return true;
         }
     }
     else
     {
         return false;
     }
 }
 public bool CreateRoom(User host, string roomName, bool isEncrypted, string password, out Room room)
 {
     room = null;
     if (rooms.Any(x => x.Value.name == roomName || x.Value.host == host))
         return false;
     else
     {
         room = new ServerRoom(this, host, roomName, isEncrypted, password);
         rooms.Add(room.id, room);
         (host as ServerUser).MoveToUserGroup(room);
         host.ready = true;
         return true;
     }
 }
 private bool CreateRoom(string roomName, bool isEncrypted, string password, out Room room)
 {
     bool result = server.lobby.CreateRoom(user, roomName, isEncrypted, password, out room);
     LobbyUpdateBroadcast(server.lobby);
     return result;
 }
 private void RoomUpdateBroadcast(Room room, List<User> users = null)
 {
     Dictionary<byte, object> parameter = new Dictionary<byte, object>
                                 {
                                     {(byte)GameRoomStatusChangeBroadcastParameterItem.GameRoomDataString, JsonConvert.SerializeObject(room.Serialize(), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }) }
                                 };
     List<Peer> peers = new List<Peer>();
     peers.Add(user.Peer);
     foreach (ServerUser targetUser in room.users.Values)
     {
         peers.Add(targetUser.Peer);
     }
     if(users != null)
     {
         foreach (ServerUser targetUser in users)
         {
             peers.Add(targetUser.Peer);
         }
     }
     server.Broadcast(peers.ToArray(), BroadcastType.GameRoomStatusChange, parameter);
 }