Persistent server variable with static room

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: 67
Joined: 13 Feb 2014, 16:09

Persistent server variable with static room

Postby moccha » 18 Jun 2019, 21:29

Hello,

I have a large list of static Rooms that are created whent he server boots. Each room has some room variables that are specific to that group. I want to save one of those room variables in permanent storage, however. The idea is that each room has one specific room var that should be kept even whent he server restarts, picking up where it left off. Is the room's room var was "55" when the server shuts down, it should start up, read the value and be "55" again.

The http://docs2x.smartfoxserver.com/AdvancedTopics/room-persistence-api says that there's an error when trying to create persistent room vars with a static room, which is what I run into. I can get the one variable to be saved, but it messes up my initialization code.

What's the best way to set it up so I can save a persistent variable for each static room?
User avatar
Lapo
Site Admin
Posts: 21836
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Persistent server variable with static room

Postby Lapo » 19 Jun 2019, 07:57

Hi,
The http://docs2x.smartfoxserver.com/Advanc ... stence-api says that there's an error when trying to create persistent room vars with a static room, which is what I run into. I can get the one variable to be saved, but it messes up my initialization code.

Yes, because when you use Room Persistence you're saving all variables, so you will find your persistent variable back to its value but you will loose the default value for all the others.

I think you should probably save the value of these variables manually, like in a database or local file. Then in your Extension you can handle the SERVER_READY event and load the saved variables and set them for each Room.

To improve our Room Persistence API in the future we could add an extra flag on Room Variables to include/exclude them from the storage.
I'll add a note in our feature TODO list.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
moccha
Posts: 67
Joined: 13 Feb 2014, 16:09

Re: Persistent server variable with static room

Postby moccha » 19 Jun 2019, 13:06

Thanks, that helps. I'd really appreciate that feature and will use it as soon as it's available.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 40 guests