PDA

View Full Version : How to detect if a room is at capacity without joining it?



aardman
12-02-2008, 11:42 PM
Hi,

How can I check if a room is at capacity without actually joining it?

In my current world I create rooms dynamically, and if the capacity is hit I spawn a new version of that room in the same zone.

If I had 100 players in a zone, with a room cap of 25 then the 101st player would currently try and join rooms 1 through 4 (hitting room cap errors on each) before creating room 5. How can I skip these checks and know to create room 5 right away?

Should I be getting a list of rooms from the zone and then querying them that way? Or is this going to need something server-side?

All rooms are dynamic, this is AS3 with codebase 4.0.6

Cheers,

Rich

MikeParks
12-03-2008, 02:02 AM
I'd try doing a GetRoomsInZoneRequest before joining any rooms and check the list of rooms returned in the GetRoomsInZoneResponse. For example:


public function onGetRoomsInZoneResponse(e:GetRoomsInZoneResponse) :void
{
for each (var currRoom:Room in e.getRooms())
{
if (currRoom.getUserCount() != currRoom.getCapacity())
{
// can join. make note of this somewhere for later use.
}
}
}

tcarr
12-03-2008, 02:05 AM
Another possibility is using GameManager, and making a CreateOrJoinGameRequest. That will join you to a room if it's allowed and there's one open, and if there isn't, it will create a new room.