Page 1 of 1

[solved] Using same Java extension in multiple zones

Posted: 07 Nov 2013, 15:18
by JohnnyD
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..

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

Posted: 11 Nov 2013, 01:17
by rjgtav
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

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

Posted: 11 Nov 2013, 11:48
by JohnnyD
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.

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

Posted: 12 Nov 2013, 12:47
by JohnnyD
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!

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

Posted: 14 Nov 2013, 01:42
by rjgtav
Great!
Sorry but I wasn't able to check the forums yesterday, glad you found it ;)