Room extension cannot get static objects

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

Moderators: Lapo, Bax

tropyw
Posts: 9
Joined: 23 Jul 2020, 16:52
Contact:

Room extension cannot get static objects

Postby tropyw » 03 Sep 2020, 16:06

Hello,
I'm using java extension and I have a room extension for a two players game, but I have a problem trying to get static objects on other classes.
For example: I have a zone extension class named MainExt, and I have a static object there (mode). this object tells me if this is a dev mode or prod.
This mode object sets with config properties while the MainExt class starts init.
I think I know why I can't reach this object only in a room extension (getting null), but I don't know what can I do to get this mode object from this specific class without the solution of creating this object in every single room extension.
Thanks.
User avatar
Lapo
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room extension cannot get static objects

Postby Lapo » 04 Sep 2020, 10:03

Hi,
the problem is due to the fact that Extensions exist in separate class loaders and therefore they can't share data.
See here:
http://docs2x.smartfoxserver.com/Extens ... assLoading

Also check this article from our blog:
https://smartfoxserver.com/blog/the-singleton-solution/

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

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Aldenea, DavinVicy, DerikFent, JerodSa, Kevengar and 30 guests