User disappears from room

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

Moderators: Lapo, Bax

OhMyOhmit
Posts: 18
Joined: 24 Apr 2018, 12:25

User disappears from room

Postby OhMyOhmit » 15 Jul 2018, 15:23

Hello everyone. I've got some strange trouble. So, I have a Unity client, which I use to control npcs in a room. It does not spawn a player entity and I never set position for this client - only npcs. Everything worked perfectly - I was sending requests from this client to server and from server to all clients in npc's AOI. But after not a long time I get this:
18:14:47,778 WARN [SFSWorker:Ext:3] v290.ExtensionReqController - com.smartfoxserver.v2.exceptions.SFSExtensionException: User cannot invoke Room extension if he's not joined in that Room. ( User Name: NpcSpawner, Id: 0, Priv: 0, Sess: 127.0.0.1:61022 ) , [ MMORoom: MMOROOM, Id: 2, Group: default, AOI: (50.0, 20.0, 50.0) ]
com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:145)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

In my AdminTool I can see that npc-client is disappearing from it's room, but it is still connected to smartfox, there are two players in a zone.
This is the code I use:

Code: Select all

SmartFoxServer.getInstance().getAPIManager().getSFSApi().sendExtensionResponse("check", response,
    SmartFoxServer.getInstance().getUserManager().getUserByName("NpcSpawner"),
                        user.getLastJoinedRoom(), false);

I've put this code in User Variables Change Handler for detecting npcs nearby my player-user, so user.getLastJoinedRoom() returns a room where a player and npc are both in.
SmartFoxServer.getInstance().getUserManager().getUserByName("NpcSpawner") is something I've tried to prevent this problem. I've already triend user.getLastJoinedRoom().getUserByName(string) and user.getZone().getUserByName(string) - same issue everytime.
Any ideas?
User avatar
Lapo
Site Admin
Posts: 20840
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: User disappears from room

Postby Lapo » 18 Jul 2018, 11:20

In my AdminTool I can see that npc-client is disappearing from it's room, but it is still connected to smartfox, there are two players in a zone.

It's difficult to say what might be going on.
You should check the server log files at the time the Unity client left the Room to see if there's some error.
SFS2X does not kick users outside of a Room, so either there's an exception or some other request was sent from the client causing the client to leave.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
OhMyOhmit
Posts: 18
Joined: 24 Apr 2018, 12:25

Re: User disappears from room

Postby OhMyOhmit » 18 Jul 2018, 15:22

Lapo wrote:
In my AdminTool I can see that npc-client is disappearing from it's room, but it is still connected to smartfox, there are two players in a zone.

It's difficult to say what might be going on.
You should check the server log files at the time the Unity client left the Room to see if there's some error.
SFS2X does not kick users outside of a Room, so either there's an exception or some other request was sent from the client causing the client to leave.

Thanks

that's all I get in smartfox.log:
[SPOILER]

Code: Select all

18 июл 2018 | 18:06:52,751 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 19, Type: DEFAULT, Logged: No, IP: 127.0.0.1:53693 } on Server port: 9933 <---> 53693
18 июл 2018 | 18:06:52,792 | INFO  | SFSWorker:Sys:2 | v2.api.SFSApi |     | User login: { Zone: BasicExamples }, ( User Name: NpcSpawner, Id: 18, Priv: 0, Sess: 127.0.0.1:53693 ) , Type: Unity
18 июл 2018 | 18:06:53,039 | INFO  | SFSWorker:Sys:3 | v2.api.SFSApi |     | Room joined: [ MMORoom: MMOROOM, Id: 2, Group: default, AOI: (50.0, 20.0, 50.0) ], { Zone: BasicExamples }, ( User Name: NpcSpawner, Id: 18, Priv: 0, Sess: 127.0.0.1:53693 ) , asSpect: false
18 июл 2018 | 18:08:21,403 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 20, Type: DEFAULT, Logged: No, IP: 127.0.0.1:53703 } on Server port: 9933 <---> 53703
18 июл 2018 | 18:08:21,458 | INFO  | SFSWorker:Sys:4 | v2.api.SFSApi |     | User login: { Zone: BasicExamples }, ( User Name: der, Id: 19, Priv: 0, Sess: 127.0.0.1:53703 ) , Type: Unity
18 июл 2018 | 18:08:21,487 | INFO  | SFSWorker:Sys:1 | v2.api.SFSApi |     | Room joined: [ MMORoom: MMOROOM, Id: 2, Group: default, AOI: (50.0, 20.0, 50.0) ], { Zone: BasicExamples }, ( User Name: der, Id: 19, Priv: 0, Sess: 127.0.0.1:53703 ) , asSpect: false
18 июл 2018 | 18:08:34,358 | WARN  | SFSWorker:Ext:2 | controllers.v290.ExtensionReqController |     | com.smartfoxserver.v2.exceptions.SFSExtensionException: User cannot invoke Room extension if he's not joined in that Room. ( User Name: NpcSpawner, Id: 18, Priv: 0, Sess: 127.0.0.1:53693 ) , [ MMORoom: MMOROOM, Id: 2, Group: default, AOI: (50.0, 20.0, 50.0) ]
   com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:145)
   com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
   java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   java.lang.Thread.run(Unknown Source)
[/SPOILER]
And the error repeats everytime when player is moving(the request is sending from server to all clients). But the interesting part is that in Client, which controls the npc, the npc is still chasing the player. :?
Maybe the problem is in this code?

Code: Select all

@Override
    public void handleClientRequest(User sender, ISFSObject params)
    {
      if(!sender.isConnected()) return;
      if(!MMORoomDemoExtension.mobs.isEmpty())
         for(int i = 0; i < MMORoomDemoExtension.mobs.size(); i++)
         {
            if(MMORoomDemoExtension.mobs.get(i).getId() == params.getInt("id"))
            {
               MMORoomDemoExtension.mmoApi.setMMOItemPosition(MMORoomDemoExtension.mobs.get(i),
                     new Vec3D(params.getFloat("x"), params.getFloat("y"), params.getFloat("z")),
                     sender.getLastJoinedRoom());
               sendPositionToClients(MMORoomDemoExtension.mobs.get(i).getId(),
                     params.getFloat("x"), params.getFloat("y"), params.getFloat("z"),
                     params.getFloat("rot"),
                     sender.getCurrentMMORoom().getProximityList(
                           new Vec3D(params.getFloat("x"), params.getFloat("y"), params.getFloat("z"))));
            }
            //System.out.println("false: " + MMORoomDemoExtension.mobs.get(i).getId() + "/" + params.getInt("id"));
         }
    }

   private void sendPositionToClients(int id, float x, float y, float z, float rot,
         List<User> list)
   {
        ISFSObject response = new SFSObject();
        response.putInt("id", id);
        response.putFloat("x", x);
        response.putFloat("y", y);
        response.putFloat("z", z);
        response.putFloat("rot", rot);
        send("movebot", response, list);
   }

But still, why does it disappear from room?.. :(
User avatar
Lapo
Site Admin
Posts: 20840
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: User disappears from room

Postby Lapo » 19 Jul 2018, 07:47

Does the spawner have a position in the MMORoom?
This is a necessary requirement. You can join an MMORoom with any User but you need to set an initial position so that the system can keep track of where everyone is.

If you don't, after 30 seconds, you're kicked off the Room. Maybe that's the problem

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
OhMyOhmit
Posts: 18
Joined: 24 Apr 2018, 12:25

Re: User disappears from room

Postby OhMyOhmit » 19 Jul 2018, 11:04

Lapo wrote:Does the spawner have a position in the MMORoom?
This is a necessary requirement. You can join an MMORoom with any User but you need to set an initial position so that the system can keep track of where everyone is.

If you don't, after 30 seconds, you're kicked off the Room. Maybe that's the problem

Cheers

Didn't test it yet, but I believe this is a true reason. Thank you so much :D .

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Jochanan and 11 guests