Extensions sorting

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

Moderators: Lapo, Bax

Rickyman
Posts: 1
Joined: 08 Feb 2022, 10:52

Extensions sorting

Postby Rickyman » 15 Jul 2022, 09:29

Hi,
We are starting to have a good few numbers of extensions on our server with a hierarchy like this in SFS2X/extensions/:
  • ZoneExtension/ZoneExtension.jar
  • ZoneExtensionDev/ZoneExtensionDev.jar
  • RoomExtension1/RoomExtension1.jar
  • RoomExtension1Dev/RoomExtension1Dev.jar
  • etc
As we are maintaining up to 3 different versions (Prod, Dev and Legacy) the number increases twice per RoomExtension created, as we create one per multiplayer minigame in our game.
Our problem is that as indicated in the documentation each extension must be in a folder inside the /extensions/ folder, so we can't sort them as we intended by folders.
So we tried to use this hierarchy:
  • Prod
    • ZoneExtension.jar
    • RoomExtension1.jar
  • Dev
    • ZoneExtension.jar
    • RoomExtension1.jar
  • ...
With 3 room extensions per folder, each with a different class name and being loaded dynamically from an string indicating the extension name (each being Legacy or Dev) and its extension class and it was working properly, until we tried loading the second room extension, then our room extension init method started falling on the first line when we were calling the constructor of another class.

Code: Select all

Exception: java.lang.NoSuchMethodError
Message: room.simulation.RoomData.<init>(Lroom/RoomExtensionLegacy;)V
Description: Extension initialization failed.
+--- --- ---+
Stack Trace:
+--- --- ---+
room.RoomExtensionLegacy.init(RoomExtensionLegacy.java:45)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoomExtension(SFSRoomManager.java:239)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoom(SFSRoomManager.java:186)
com.smartfoxserver.v2.entities.SFSZone.createRoom(SFSZone.java:258)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:759)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:726)
Handlers.Users.UserRequestToJoinRoomHandler.CreateNewRoom(UserRequestToJoinRoomHandler.java:121)
Handlers.Users.UserRequestToJoinRoomHandler.handleClientRequest(UserRequestToJoinRoomHandler.java:42)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:208)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:174)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

Moving the extension to its own folder in extensions and updating the name references made it work as intended again.
Is the folder sorting that we want possible? Are we doing something wrong?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extensions sorting

Postby Lapo » 15 Jul 2022, 13:15

Hi,
the way in which jar files are organized in folders is not that important, but the structure is. Extensions are loaded only when they exist in a directory under SFS2X/extensions/.

Whether you create one folder per jar file, or you group all jar files under the same directory and all variations in between is not that important. You can choose whichever system works best for you.

As regards the error you have reported the message is pointing to a non existent method, so you probably need to double check the compilation and deployment of that class, and relative jar file.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 50 guests