How to block roomList updates?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Gentleman
Posts: 29
Joined: 05 Jun 2009, 21:20

How to block roomList updates?

Postby Gentleman » 30 Jun 2009, 21:29

Is it possible to block or restrict the number of rooms is sent when a roomList update event is triggered. I actually don't even want this event but the flash doesn't seem to work correctyly if it doesn't get at least one room list update when loggin in.

My issue is I have thousands of rooms dynamically created on the server and the flash doesn't need to know about them. Buy my send room list call is part of the login code and it sends the list of all the rooms. If I don't send the room list, I find that the connection between the flash and sever will drop much faster than the timeout set for the connection.
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 01 Jul 2009, 05:34

Can't you make an extension that intercepts the RoomListUpdate (or something like that) event? Just like the login extension intercepts the login event.. Then do stuff to it and send it to the client, for example only give him the first room or a fixed, single room name.
Gentleman
Posts: 29
Joined: 05 Jun 2009, 21:20

Postby Gentleman » 01 Jul 2009, 16:26

I don't think there is an InternalEventObject for the roomList update. In my case, this wouldn't matter because I am calling sendRoomList() after a user successfully login from the server and so it is not a client triggered event. What I am really looking for is a way to control what sendRoomList() function in java sends.
User avatar
Lapo
Site Admin
Posts: 21276
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Jul 2009, 05:17

Is it possible to block or restrict the number of rooms is sent when a roomList update event is triggered. I actually don't even want this event but the flash doesn't seem to work correctyly if it doesn't get at least one room list update when loggin in.

You can fake the roomList message sending only the details of the room that you need.

It can be done by using the sendGenericMessage method that allows to send any data to the client. Here's a snippet of Actionscript code that sends a room list containing one room only:

Code: Select all

// Only send info about the current room
function sendSmallRoomList(r, who)
{
   var msg = "<msg t='sys'><body action='rmList' r='-1'>"
   
   msg += "<rmList><rm id='" + r.getId()
   msg += "' priv='" + (r.isPrivate() ? "1" : "0")
   msg += "' temp='" + (r.isTemp() ? "1" : "0")
   msg += "' game='" + (r.isGame() ? "1" : "0")
   msg += "' ucnt='" + (r.getUserCount())
   msg += "' maxu='" + r.getMaxUsers()
   msg += "' maxs='" + r.getMaxSpectator()
   msg += "'><n><![CDATA[" + r.getName() + "]]></n></rm></rmList>"

   msg += "</body></msg>"

   _server.sendGenericMessage(msg, null, [who])
}
Lapo
--
gotoAndPlay()
...addicted to flash games
Gentleman
Posts: 29
Joined: 05 Jun 2009, 21:20

Postby Gentleman » 07 Jul 2009, 17:28

Thx Lapo, this worked for me.
fluffy
Posts: 20
Joined: 26 Jun 2007, 18:26

Postby fluffy » 11 Jan 2010, 13:27

Thanks, I also used it.

But my problem is, that i also need to send variables.
Can you tell me how to put that into xml?

Regards,
Fluffy
User avatar
Lapo
Site Admin
Posts: 21276
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 Jan 2010, 16:49

Hi,
I would suggest to check a real roomList message directly in your Flash output (set the API debug option to true) and learn the XML structure from there.
Lapo

--

gotoAndPlay()

...addicted to flash games
aardee
Posts: 2
Joined: 13 Apr 2010, 23:47

Blocking roomlist updates

Postby aardee » 13 Apr 2010, 23:52

We have a custom login extension that sends the roomlistupdate to the client after login. However, we noticed that clients continue to get roomlistupdates from the server periodically as there are changes to the number of users in a room. Is there a way to switch off this behavior? We want clients to request a new room list when they want one rather than have it pushed to them.

Thanks in advance for any advice.
User avatar
Lapo
Site Admin
Posts: 21276
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Apr 2010, 13:01

In general that's not a good idea.
You can suppress the userCount updates which informs you in real time of the number of users in any Room.
I would not recommend stopping the updates that notify new Rooms being added or removed.
An example is that if you don't get updates for the Rooms that are removed you might attempt to join Rooms that don't exist anymore.

Each Room created can be configured not to fire userCoutUpdates.
You can also inhibit other events if you wish to and once you understand the consequences of that.

All the details are found in Chapter 2.1 of the docs:
http://www.smartfoxserver.com/docs/
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 4 guests