Static Variables (Shared Between Extensions)

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

Moderators: Lapo, Bax

hamedn
Posts: 31
Joined: 17 Apr 2012, 17:40

Static Variables (Shared Between Extensions)

Postby hamedn » 13 Jul 2012, 13:33

Hi Everybody,

I've been trying to use static variable to transmit data between 2 extensions, but it seems like each extension has their own, isolated instance of the variable.

I searched the forums and it came up with this (from SFS1): viewtopic.php?f=4&t=11643&hilit=sharing+variables

Based on that, I changed my .bat file (Windows) to be as follows:

Code: Select all

@..\jre\bin\java.exe -cp "./;lib/*;lib/Jetty/*;extensions/__lib__/*;./javaExtensions/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main %1 %2


Unfortunately, the problem still persists. Did I change my server file the wrong way, has SFS2X built a different system that requires different modifications, and/or is there some other way to send a string or a reference to a room from one extension to another?

Thanks :mrgreen:

Hamed
Devon
Posts: 41
Joined: 12 Apr 2011, 16:18

Re: Static Variables (Shared Between Extensions)

Postby Devon » 14 Jul 2012, 03:53

Not sure if this is what you're looking for but you may look into: [ handelInternalMessage() ]
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Static Variables (Shared Between Extensions)

Postby Lapo » 14 Jul 2012, 08:35

Static variables are evil :twisted:
Because each extension runs in its separated class loader. Read here:
http://docs2x.smartfoxserver.com/Advanc ... extensions
Read the "Class loading architecture" section

I would second Devon's suggestion.
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 117 guests