Room variable resource usage

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
moccha
Posts: 112
Joined: 13 Feb 2014, 16:09

Room variable resource usage

Postby moccha » 23 Apr 2019, 18:23

A question regarding use of resources. I was looking into a resource efficient way to tell users a room is no longer joinable, i.e. the game started. I thought maybe to set the room to isHidden, but I see that the client's wont see updates when the room is set back to isHidden(false) again.

I have a implementation working now where every single room has a global variable "isOpen" that is set to false when the game starts and set to true when the game finishes. I have hundreds of rooms however, and per the documentation (http://docs2x.smartfoxserver.com/DevelopmentBasics/server-variables), this may be a problem with heavy traffic:

isGlobal: a global Room Variable is visible from outside the Room. This means that any user will be able to access it and receive updates even if he's not joined the Room. Running too many global Variables can use significant bandwidth in a high traffic server. Use with moderation (default == false).


Is there a more efficient way to create a flag that is visible outside of the room that the client receives in updates?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room variable resource usage

Postby Lapo » 24 Apr 2019, 07:10

Hi,
what you're doing is correct. The very minimum you can do for this feature to work is to tell all players interested in a certain Room that such Room is now open/closed. Hence the use of global Room Vars.

What you could optimize is the number of people that receive the update. How? By using Room Groups and subscribing users to these groups based on criteria that make sense for your game.

For instance you if your game has different ranks, or modes, or any other categories you could assign Rooms to different groups and let users join/leave these groups to avoid send them the whole Room list.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: johnnikson and 117 guests