Hello.
I've been trying to work this out, but can't seem to find the right way to do what I need...
Lets say I want to send me newly logged client a list of the last 10 rooms to be created.
When I ask the zone for the rooms list, using, of course, zone.getRooms(), the list returned in not in order of the rooms by the time of their creation.
Since sortOn is not supported on the server, meaning I can't sort the rooms (all dynamic rooms) by their id, and I can't sort to the correct order using simple sort after, for example, converting the data into strings, since room_id_10 will come before room_id_2, or even, should I try 10_room, it will still come before 2_room, what can you suggest to make this kind of sort work, or is there some kind of command I'm missing or some parameters I could pass the getRooms function to give me back the rooms by order??
Thanks.
Yuval Lahav.
A probelm with sorting rooms list after zone.getRooms()
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
As far as I recall, I don't think there's a such feature that sorts the room by a parameter. You could easily create a custom function to do so.
i.e. loop through each room, and add to an array by its id - then select the last 10 elements of the array. Then you send the room list by using helper.sendCustomRoomList method (for java) or _server.sendGenericMessage method to send your own xml message to fake a room list. More info can be found in the docs.
i.e. loop through each room, and add to an array by its id - then select the last 10 elements of the array. Then you send the room list by using helper.sendCustomRoomList method (for java) or _server.sendGenericMessage method to send your own xml message to fake a room list. More info can be found in the docs.
Smartfox's forum is my daily newspaper.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Well, I don't think that would help much, since creating an array and using the ID of the room as the index would create a really big and long array (as the server works through the day, creating and killing off rooms, they ID's get to the 10,000nd's, and then, taking the last 10 would not be that good too as rooms are created and killed off all the time, so I would have to work to eliminate the empty spaces, and to do all of that, over and over and over again for each user who logs in, just to see the last 10 rooms created, for about 5000 clients, and 5000 connections, seems to me it will take a lot of the server processing power, let alone delay it will create on the server, let alone number of messages I want to cut down....
I'll find something out, I'm sure... I hope...
I'll find something out, I'm sure... I hope...
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact: