How to enable multiple extension jars per zone?

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
Andy608
Posts: 17
Joined: 02 Aug 2017, 05:21

How to enable multiple extension jars per zone?

Postby Andy608 » 02 Aug 2017, 05:29

Hello,

I am new to SmartFoxServer. From what I currently understand, each extension goes in a different jar file.

I currently have a custom Login Extension and I just finished working on a custom Signup Extension. Both of these extensions are in their own jar files. My question is, how do I add both of these extensions to one zone? In the Admin Panel under Zone Configurator > Zone Extension there is only one option for a jar file and main java file.

How do I add both of my separate extensions (in separate jar files) to one zone? Or am I doing this wrong and should I only have one jar for all of my extensions? If so, how would the main class work?

Ideally, I would like to have multiple jar files but I don't see any documentation on how to set it up that way. I can only find tutorials on how to set up your first extension.

Any help would be greatly appreciated.

Thanks,
Andrew
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to enable multiple extension jars per zone?

Postby Lapo » 02 Aug 2017, 07:49

Hello and welcome :)
Andy608 wrote:I am new to SmartFoxServer. From what I currently understand, each extension goes in a different jar file.

No, you can do pretty much whatever you want.
You can put multiple Extensions in one jar or every extension in separate jar or every other permutation. It all really depends on how you need to organize your code.

In your specific case I'd recommend one jar, for the reasons I explain below.

I currently have a custom Login Extension and I just finished working on a custom Signup Extension. Both of these extensions are in their own jar files. My question is, how do I add both of these extensions to one zone?

You don't :)
An Extension has a single "entry point", your main Extension class which is whatever class you designate as the main.
From there you add any number of request handlers that will dispatch specific requests to your code.

So you don't need to add multiple Extensions to a Zone, instead you create a main class (which extends SFSExtension) and from there you add as many request (and event) handler as you need.

Makes sense?

In your specific case you could add a listener for the LOGIN event and a request handler for the signup request.

For more on this take a look here:
http://docs2x.smartfoxserver.com/Extens ... a/overview

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Andy608
Posts: 17
Joined: 02 Aug 2017, 05:21

Re: How to enable multiple extension jars per zone?

Postby Andy608 » 19 Aug 2017, 21:47

Ahhh yes, I understand now.

As new questions arise, I will be sure to post them on the forum.

Thank you for your help Lapo!

~Andy608

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Thomasea and 64 guests