Zone extension from Room extension

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

Moderators: Lapo, Bax

LuffyGray
Posts: 32
Joined: 06 Feb 2017, 16:01

Zone extension from Room extension

Postby LuffyGray » 22 Mar 2017, 11:50

I'm aware you can access the zone extension from a room extension but is it possible to call API you have created in the zone extension from the room after getting hold of a reference?

Code: Select all

Zone extension:
       MongoDB.java <--- I want to access this class

Room extension:
       Main.java
              ZoneExtensionReference  <--- From this reference

Thank you.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Zone extension from Room extension

Postby Lapo » 22 Mar 2017, 14:17

By default the two classes would be in two separate class loaders, so the default answer is ... no.

Of course you can use other ways to achieve what you're asking:
http://docs2x.smartfoxserver.com/Advanc ... assLoading

such as deploying the common classes in the top class loader, or even the whole extension code if you don't mind giving up runtime reloading.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
LuffyGray
Posts: 32
Joined: 06 Feb 2017, 16:01

Re: Zone extension from Room extension

Postby LuffyGray » 22 Mar 2017, 15:02

That's perfect, thank you
LuffyGray
Posts: 32
Joined: 06 Feb 2017, 16:01

Re: Zone extension from Room extension

Postby LuffyGray » 22 Mar 2017, 16:39

Lapo wrote:By default the two classes would be in two separate class loaders, so the default answer is ... no.

Of course you can use other ways to achieve what you're asking:
http://docs2x.smartfoxserver.com/Advanc ... assLoading

such as deploying the common classes in the top class loader, or even the whole extension code if you don't mind giving up runtime reloading.

Hope it helps


quick addtional question, if all of the extension include a reference to a class from a library within smartfox /Lib folder, are each of these references a seperate instance?

If so I'll have to create some static references instead
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Zone extension from Room extension

Postby Lapo » 22 Mar 2017, 17:06

/Lib doesn't exist :)

You mean SFS2X/lib/ ?
Lapo

--

gotoAndPlay()

...addicted to flash games
LuffyGray
Posts: 32
Joined: 06 Feb 2017, 16:01

Re: Zone extension from Room extension

Postby LuffyGray » 22 Mar 2017, 17:36

Aye I do, I've managed to get it working, I just improvised a java static class (Oh how I wish you designed the back end in C#) and now its globally accessible so thank you.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 53 guests