Cannot resolve method 'getParentZone()'

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
Wei
Posts: 50
Joined: 13 Jun 2017, 08:16

Cannot resolve method 'getParentZone()'

Postby Wei » 01 Aug 2017, 00:30

I want to create a game room

Code: Select all

try {
            Room nRoom = getApi().createRoom(getParentZone(), cfg, user);
            getApi().joinRoom(user, nRoom);
        } catch (SFSJoinRoomException | SFSCreateRoomException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


but there's an error says Cannot resolve method 'getParentZone()'

so I changed my code to

Code: Select all

Zone zone = getParentExtension().getParentZone();

try {
            Room nRoom = getApi().createRoom(zone, cfg, user);
            getApi().joinRoom(user, nRoom);
        } catch (SFSJoinRoomException | SFSCreateRoomException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


the room was created, but some error message showed

Code: Select all

08:36:19,425 WARN  [SFSWorker:Ext:2] managers.SFSRoomManager     - com.smartfoxserver.v2.exceptions.SFSExtensionException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSExtensionException
Message: Extension boot error. The provided path is not a directory: extensions/ExtName
Description: Failure while creating room extension.
Possible Causes: If the CreateRoom request was sent from client make sure that the extension name matches the name of an existing extension
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createJavaExtension(SFSExtensionManager.java:346)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:260)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoomExtension(SFSRoomManager.java:247)
com.smartfoxserver.v2.entities.managers.SFSRoomManager.createRoom(SFSRoomManager.java:194)
com.smartfoxserver.v2.entities.SFSZone.createRoom(SFSZone.java:272)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:733)
com.smartfoxserver.v2.api.SFSApi.createRoom(SFSApi.java:703)
com.mazing.testextension.CreateRoomHandler.handleClientRequest(CreateRoomHandler.java:86)
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:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

08:36:19,426 INFO  [SFSWorker:Ext:2] managers.SFSRoomManager     - Room created: { Zone: Test }, [ Room: 560634, Id: 8, Group: lf4, isGame: true ], type = SFSRoom
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Cannot resolve method 'getParentZone()'

Postby Lapo » 01 Aug 2017, 07:33

Your code is correct and there's nothing wrong with getting a referenze to the Zone.
The error says that:

Code: Select all

The provided path is not a directory: extensions/ExtName

which indicates that the path to the Extension you have provided is incorrect and the Extension class could not be loaded.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Wei
Posts: 50
Joined: 13 Jun 2017, 08:16

Re: Cannot resolve method 'getParentZone()'

Postby Wei » 01 Aug 2017, 11:03

If the Extension class could not be loaded, how could it work? My extension is working, I'm a little confused.

And I still don't know what's wrong with getParentZone(), I saw it almost everywhere, your docs and blog, always

Code: Select all

Room nRoom = getApi().createRoom(getParentZone(), cfg, user);


Do I need to import any class?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Cannot resolve method 'getParentZone()'

Postby Lapo » 01 Aug 2017, 13:35

It is referring to the Room Extension.
Your Room creation code specifies an Extension that must be initialized when the Room is created.
That's the one the server is having problems with.

Double check the CreateRoomSettings parameters that you're passing to the createRoom(...) method.
(In other words cfg, in your example code)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Wei
Posts: 50
Joined: 13 Jun 2017, 08:16

Re: Cannot resolve method 'getParentZone()'

Postby Wei » 01 Aug 2017, 13:54

Thanks man, I modified my code, and it's ok now

Code: Select all

cfg.setExtension(new CreateRoomSettings.RoomExtensionSettings("GameExtension", "com.mazingtec.ftlextension.GameExtension"));

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 135 guests