[solved] Using same Java extension in multiple zones

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

[solved] Using same Java extension in multiple zones

Postby JohnnyD » 07 Nov 2013, 15:18

I want to run two different zones on a SFS server, using the same extension but different DB-managers. I set this up and I see both zones are running but it seems like both are using the same DB manager, and the same zone. e.g. I connect to zone_2 but the player logs into the lobby for zone_1.

My XML looks a bit like this:

Code: Select all

<Zone name="game" uCountUpdate="false" buddyList="20" maxUsers="100" customLogin="true" roomListVars="true">
         <MaxRoomNamesLen>40</MaxRoomNamesLen>
         <MaxUserNamesLen>40</MaxUserNamesLen>
         <Rooms>
            <Room name="lobby" isGame="false" maxUsers="100" isPrivate="false" isTemp="false" autoJoin="true" />
         </Rooms>
         <Extensions>
            <extension name="game" className="johnnyd.server.GameServer" type="java" />
         </Extensions>
         <AutoReloadExtensions>false</AutoReloadExtensions>
         <DatabaseManager active="true">
            <Driver>com.mysql.jdbc.Driver</Driver>
            <ConnectionString>jdbc:mysql://localhost:3306/gameDB</ConnectionString>


Code: Select all

      <Zone name="game_test" uCountUpdate="false" buddyList="20" maxUsers="100" customLogin="true" roomListVars="true">
         <MaxRoomNamesLen>40</MaxRoomNamesLen>
         <MaxUserNamesLen>40</MaxUserNamesLen>
         <Rooms>
            <Room name="lobby" isGame="false" maxUsers="100" isPrivate="false" isTemp="false" autoJoin="true" />
         </Rooms>
         <Extensions>
            <extension name="game_test" className="johnnyd.server.GameServer" type="java" />
         </Extensions>
         <AutoReloadExtensions>false</AutoReloadExtensions>
         <DatabaseManager active="true">
            <Driver>com.mysql.jdbc.Driver</Driver>
            <ConnectionString>jdbc:mysql://localhost:3306/testDB</ConnectionString>


It seems like only a single instance of the extension is being created, and shared singleton-style.

Is what I'm trying to do allowed and if so are there any known problems... of course it's possible my code is to blame but I want to check this first..
Last edited by JohnnyD on 12 Nov 2013, 12:45, edited 1 time in total.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Using same Java extension in multiple zones... problems!

Postby rjgtav » 11 Nov 2013, 01:17

Hello,

As I don't have much time, I've only tested by creating 2 very simple zones with a same simple Java extension and it created two different instances.
Here is the config I've used:

Code: Select all

<Zone name="javaExtTest1" customLogin="false" buddyList="20">
   <Rooms>
      <Room name="MainRoom" maxUsers="10" isPrivate="false" isTemp="false" autoJoin="true" />
   </Rooms>
   <Extensions>
      <extension name="javaExt"  className="it.gotoandplay.extensions.examples.SimpleExtension" type="java" />
   </Extensions>
</Zone>
<Zone name="javaExtTest2" customLogin="false" buddyList="20">
   <Rooms>
      <Room name="MainRoom" maxUsers="10" isPrivate="false" isTemp="false" autoJoin="true" />
   </Rooms>
   <Extensions>
      <extension name="javaExt"  className="it.gotoandplay.extensions.examples.SimpleExtension" type="java" />
   </Extensions>
</Zone>


Are you sure that if you login into two different zones, the player will join the same one?
Can you confirm that trough the adminTool?
Does that also happen if you use on of the official examples and just change the zone to login?

Cheers
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.
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Re: Using same Java extension in multiple zones... problems!

Postby JohnnyD » 11 Nov 2013, 11:48

Thanks for your test - can you elaborate what it meant by "it created two different instances"?

I will re-test and add more logging on client AND server so I can be 100% sure which zones/rooms both sides think are used. But I already definitely checked the same room-id was used in both cases... my lobby rooms have ids 1 & 2 and both users logged into room 1. Of course I also need to be ABSOLUTELY sure my client isn't simply connecting to to the live zone in both cases due to a stupid coding error before going further :)

edit: one thing I wasn't sure of was if I should give the extensions different names in each zone, or use the same name since it's the same extension.
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Re: Using same Java extension in multiple zones... problems!

Postby JohnnyD » 12 Nov 2013, 12:47

JohnnyD wrote:Of course I also need to be ABSOLUTELY sure my client isn't simply connecting to to the live zone in both cases due to a stupid coding error before going further :)


Fixed it - turned out our init() method was hardcoding the name of the zone rather than getting the parent zone using the API.

Thanks for your test anyway, it gave me the confidence to be sure my code was the problem!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: [solved] Using same Java extension in multiple zones

Postby rjgtav » 14 Nov 2013, 01:42

Great!
Sorry but I wasn't able to check the forums yesterday, glad you found it ;)
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 “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 4 guests