||unity-dev|| Room spawning

unity-dev@moock.org unity-dev@moock.org
Tue Apr 26 15:09:01 2005


Hi James,

ClientServices is just an interface so you wouldn't be able to override 
the joinRoom method there.

But what you could do is write some custom Room behaviour to handle this.  
To keep things as simple as possible I will illustrate using just Rooms.  
You will have to deploy 1 Room which nobody ever joins but acts as a 
manager for loading clients in to real chat Rooms.  For this example I 
will call it RoomController.  It is to this Room that all clients will request 
to join a Chat Room.  They don't specify the actual name of a real 
Chat Room on the sever they just make a custom request like 
"joinChatRoom".  

The RoomController will have a list of all the current 
ChatRooms that have been created (it may just start with 1).  It goes 
thru the list of Rooms in order and when it finds one that's empty it 
calls ClientServices.joinRoom for the client that particular Room.  If all 
existing Chat Rooms are full the RoomController will create a new Chat 
Room and tell the client to join that new Room.  

The onRoomDie method of each ChatRoom will want to let the RoomController 
know they have been removed so that RoomController can remove them from 
the master list.  Also I would recommend always trying to join the Rooms 
in order (eg. xxx1, xxxx2, xxx3) so that as load is reduced the Rooms at 
the end of the list will become empty and can be removed.

I hope that helps.  I can go in to more detail with any specific questions 
about this that you may have.

Regards,

Derek

On Tue, 26 Apr 2005 unity-dev-admin@moock.org wrote:

> Hi,
> 
> I have a chat application that has, initially, a single room but I want
> to spawn a new room when the first is full.
> 
> Now, this can't be done on the client with a 'spawn room' message, as
> the delay in the clients knowledge of a full room means that two or more
> clients may try to spawn a new room if they attempt to join at the same
> time.
> 
> Does anyone know if I can overwrite the joinRoom method of the
> ClientServices class on the server. I would then loop through the rooms
> and join if not full, else create a new room and then join.
> 
> Thanks in advance,
> 
> James
> 
> --
> you're a unity-dev subscriber. to unsubscribe, visit www.moock.org/mailman/listinfo/unity-dev/
> 
> superb hosting for this list and moock.org is generously provided by Rackspace. See: http://www.rackspace.com/?supbid=moock
>