Dynamic extension properties (rather than static files)

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
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Dynamic extension properties (rather than static files)

Postby thomers1 » 08 Jul 2011, 06:36

hi,

http://docs2x.smartfoxserver.com/Advanc ... extensions mentions only static property-files for extensions.

i need to instantiate a (game)room-extension with parameters that i get at runtime (i.e. from the DB).

how can i achieve that?

best,
thomas
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 08 Jul 2011, 08:15

Use a DB :D
In the init() you grab the dynamic data from it.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Postby thomers1 » 08 Jul 2011, 08:25

ok, details:


Code: Select all

CreateSFSGameSettings settings = new CreateSFSGameSettings();
settings.set...
...
CreateRoomSettings.RoomExtensionSettings extSettings = new CreateRoomSettings.RoomExtensionSettings(EXT_FOLDER_NAME, EXT_NAME);
settings.setExtension(extSettings);

Room room = SmartFoxServer.getInstance().getAPIManager().getGameApi().createGame(this.getParentZone(), settings, null, false, false);


when calling createGame (or before), i need to hand over some parameters to the room extension.

should/can i subclass CreateSFSGameSettings, and (how) can i access this in the room extension?

or is there any other way to specify game-specific parameters *during* room extension instantiation *without* a static property file?

best
t
User avatar
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Postby thomers1 » 13 Jul 2011, 07:12

lapo?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Jul 2011, 16:30

1. Create the Room.
2. Populate its properties (setProperty/getProperty) with data that you need
3. Invoke a specific method on your Room extension to trigger the code that will use those properties

NICE TO HAVE: we should add an optional setRoomProperties(...) method available at creation time to populate those properties in one shot with CreateRoom
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Postby thomers1 » 18 Jul 2011, 08:20

aaah thanks.

anyway, i'm confused, since the docs state

Previously in SmartFoxServer 1.x you had Room/User Variables and Room/User Properties. With SmartFoxServer 2X all custom data is handled via Room/User Variables.


so, what's the difference between properties and private (server-side only) room variables?
User avatar
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Postby thomers1 » 28 Jul 2011, 13:47

any update?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Jul 2011, 07:14

Private Room/User Variables are... Room/User Variables! Which means you have to set/read them just like non-private Room/User Variables.
Properties are more generic instead.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 66 guests