Question regarding 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

User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

Question regarding Room Extension

Postby levancho » 11 Oct 2012, 11:03

Hi,

We have 3 types of Games,

type1
type2
type3

every type of game gets its own type Extension
gameType1Extension
gameType2Extension
gameType3Extension


now, we have a code :


Code: Select all

    public Collection<User> getRoomUsers() {
        return this.getParentRoom().getUserList();
    }


now, question is if we have three rooms of gameType1 open, will each room get its own new instance of that gameType1Extension class, or not, if they do not get each their ow instance of gameType1Extension then our code will not work, what is the workaround if that is the case? can we force to have each game its own instance of gameType1Extension?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Question regarding Room Extension

Postby rjgtav » 11 Oct 2012, 15:36

Hi.

When you attach an Extension to a room, it creates a new instance of that extension and attaches it to the room.
The only problem with this approach is that the more rooms you have, the more extension instances and classLoaders you will have (as each extension has its own classLoader), which will fill up the PermGen space quickly. The more classes you have in your extension, the quicker it will fill the PermGen space, so one way to decrease its usage is to deploy the extension dependencies inside the __lib__/ folder.

You can read more information regarding ClassLoading on SFS2x here.

Another workaround is to use a single Zone-Level Extension with the code for handling the Game Logic. This way you'll only use a single extension and a single ClassLoader, avoiding the memory overload problem.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 105 guests