Some game rooms dont show up in smartfox Zone monitor

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
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 19 Nov 2019, 06:10

Hi,
After I added new features to my game some weird thing has happend. Some game rooms being seen at client side, some users are inside of those game roooms, But I can not see them at SmartFox panel , in the zone monitor. For example there is a game room name BEZ4 I can see it at client side there are users playing game in it but when new users try to join them. We have join room JoinRoomRequestHandler extends BaseClientRequestHandler client sends the name of that game room

We have them join like this

Room room = zone.getRoomByName(room_name);
getApi().joinRoom(user, room, null, false, null);

if the room does not exist at zonemonitor users can not join the room. I can not catch the same thing in my local server. When I talk to users who are playing inside of that room, they say we are playing game inside everything is ok but other users can not enter. Maybe something tries to remove that room from smartfox, it removes it from some kind of list but room does not get destroyed.

Thanks
User avatar
Lapo
Site Admin
Posts: 21117
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some game rooms dont show up in smartfox Zone monitor

Postby Lapo » 20 Nov 2019, 15:04

Hi,
make sure that you're looking in the right Room Group.
If you don't remember what Room Group the Room belongs to do the following:

From the AdminTool > Zone Monitor double click the correct Zone.
In the Group dropdown select [Any]
Also make sure the Filter is empty (check by clicking the Filter button, if Filters are active clear them)

This way you'll get the complete list of Rooms in the Zone.
Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 21 Nov 2019, 14:17

Nop,

https://game.oyunzade.com/mobile/missing_game_room.png,
https://game.oyunzade.com/mobile/missing_game_room2.png

users that inside of them continue to play their games but new users can not join.

Thanks
User avatar
Lapo
Site Admin
Posts: 21117
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some game rooms dont show up in smartfox Zone monitor

Postby Lapo » 21 Nov 2019, 16:40

What version of SFS2X are you running?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 22 Nov 2019, 06:07

SmartFoxServer 2X (2.13.7)
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 22 Nov 2019, 07:31

I tried to get more information about disappearing rooms, one room was not being seen from zone panel and I looked at logs I saw it was created this time

22 Nov 2019 | 09:28:05,306 | INFO | SFSWorker:Ext:16 | entities.managers.SFSRoomManager | | Room created: { Zone: Pisti }, [ SFSGame: BEZ7, Id: 23456, Group: beyZade, public: true, minPlayers: 0 ], type = SFSGame
22 Nov 2019 | 09:28:05,307 | INFO | SFSWorker:Ext:16 | v2.api.SFSApi | | Room joined: [ SFSGame: BEZ7, Id: 23456, Group: beyZade, public: true, minPlayers: 0 ], { Zone: Pisti }, ( User Name: 270918, Id: 134266, Priv: 1, Sess: 85.110.234.35:42980 ) , asSpect: false

I could not enter that room When I tried I get this error in the logs

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error while handling client request in extension: { Ext: PistiExtensions, Type: JAVA, Lev: ZONE, { Zone: Pisti }, {} }
Extension Cmd: $JR
+--- --- ---+
Stack Trace:
+--- --- ---+
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

22 Nov 2019 | 09:53:45,488 | ERROR | SFSWorker:Ext:22 | controllers.v290.ExtensionReqController | | java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error while handling client request in extension: { Ext: PistiExtensions, Type: JAVA, Lev: ZONE, { Zone: Pisti }, {} }
Extension Cmd: $JR
+--- --- ---+
Stack Trace:
+--- --- ---+
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

22 Nov 2019 | 09:53:45,534 | ERROR | SFSWorker:Ext:3 | controllers.v290.ExtensionReqController | | java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error while handling client request in extension: { Ext: PistiExtensions, Type: JAVA, Lev: ZONE, { Zone: Pisti }, {} }
Extension Cmd: $JR
+--- --- ---+
Stack Trace:
+--- --- ---+
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

and when the last user left the room that room closed down I saw it on the log


22 Nov 2019 | 10:16:55,995 | INFO | SFSWorker:Ext:22 | entities.managers.SFSRoomManager | | Room removed: { Zone: Pisti }, [ SFSGame: BEZ7, Id: 23456, Group: beyZade, public: true, minPlayers: 4 ], Duration: 2930735

I can not find the reason, Users that are inside of the room continues to play the game. But other players can not enter. when the last user leaves the room it got removed

I hope this gives more clue

Thanks
User avatar
Lapo
Site Admin
Posts: 21117
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some game rooms dont show up in smartfox Zone monitor

Postby Lapo » 22 Nov 2019, 08:38

It's quite difficult to guess what might be going on without knowing what your server side code does and what other interactions are happening. To start investigating we need more info and a way to reproduce the issue. If you have a test environment you could try to reproduce the problem there.

Let us know
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 22 Nov 2019, 08:47

Hey,

This might be a clue


if we can not find it from zone

Code: Select all

Room room = zone.getRoomByName(roomName);

we use this code

if(room == null) {
            MatchExpression playNow = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true)
                    .and(RoomProperties.NAME,StringMatch.EQUALS,roomName);
            List<Room> roomList = getApi().findRooms(zone.getRoomListFromGroup(user.getSubscribedGroups().get(0)),playNow,0);
            if(roomList!= null && roomList.size() > 0) {
                room = roomList.get(0);
            }
        }

We had this problem before but we solved it with the this code but I guess one ore more room variable missing now when we called Room Join request it is causing null pointer exception


Thanks
User avatar
Lapo
Site Admin
Posts: 21117
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some game rooms dont show up in smartfox Zone monitor

Postby Lapo » 22 Nov 2019, 09:01

Hi,
are you deleting Rooms manually from you server side code? If so, can you show me the section(s) of the Extension code where you're doing it?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 22 Nov 2019, 10:58

Hi,
I have this code for deleting stuck rooms. but it never gets called because there is trace it shows which room is beeing deleted

Code: Select all

 public StuckRoomRemoveManager(SFSExtension ex) {
        sfsExtension = ex;
        sfs = SmartFoxServer.getInstance();
        stuckRoomScheduler = sfs.getTaskScheduler().scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                try {
                    tryDeletingStuckRooms();


                }catch (Exception ex){
                    sfsExtension.trace(ex.getMessage());
                }
            }
        },10, 10, TimeUnit.SECONDS);
    }



    private void tryDeletingStuckRooms(){
        Zone zone = sfsExtension.getParentZone();

        List<Room> roomList = zone.getRoomList();
        for(Room room : roomList) {
            if(room.isGame()){
                checkIfStuck(room, zone);
            }
        }
    }

    private void checkIfStuck(Room room, Zone zone) {
        List<User> userList = room.getPlayersList();
        List<User> realUsers = new ArrayList<>();
        List<User>  robots = new ArrayList<>();

        for(User usr: userList) {
            if(usr.getName().contains("_R")){
                robots.add(usr);
            }else {
                realUsers.add(usr);
            }
        }

        if(realUsers.size() == 0 && robots.size() > 0){
            for(User usr : robots){
                sfsExtension.trace("Robot disconnected Name :" , usr.getName());
                sfsExtension.getApi().disconnectUser(usr);
            }
            sfsExtension.trace("Room delete Room Name : ", room.getName());
            sfsExtension.getParentZone().removeRoom(room);
        }else {
            Room staticRoom = zone.getRoomByName(room.getGroupId());

            if(staticRoom != null) {
                List<User> playerList = room.getPlayersList();

                for(int i = 0; i < playerList.size();i++) {
                    User usr = playerList.get(i);

                    if(!usr.isNpc()){
                        if(staticRoom.getUserByName(usr.getName()) == null){
                            sfsExtension.trace("User ", usr.getName(), " salonda yok oyunda var zone.removeUser ");
                            zone.removeUser(usr);
                        }
                    }
                }
            }

        }
    }
   
   


I use this to clean the stuck users and stuck rooms there is no log for that stuck room. Other then this code room gets removed when there is no user left in the room
User avatar
Lapo
Site Admin
Posts: 21117
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some game rooms dont show up in smartfox Zone monitor

Postby Lapo » 22 Nov 2019, 15:40

For starters I am not sure what a "stuck Room" represent exactly in your game.
Can you clarify?

I see you're checking this condition:

Code: Select all

 if(realUsers.size() == 0 && robots.size() > 0)

So I assume a "stuck Room" is one where there are no real players, but there are a number of NPCs.
Why testing this every few seconds, instead of testing this when the USER_LEAVE_ROOM event is fired. This way it's triggered at the right time, instead of cycling on every Room every few seconds.

Also this is a problem:

Code: Select all

 sfsExtension.getParentZone().removeRoom(room);

by removing Rooms like this the client will never be updated, causing a desync between their room list and the what's on the server side.
Instead you should call --> SFSApi.removeRoom(...)

A similar problem exists when you call zone.RemoveUser(). This is very problematic because it makes the User an orphan on the server side (he/she no longer exists in that zone) without clearing up all the necessary in-memory data, linked to the User (variables etc...).
Also it doesn't trigger any update event for the other players.

If you want to remove a player from a Zone you must either use SFSApi.logout(User) or SFSApi.disconnect(User).

Make sure to fix these aspects.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 25 Nov 2019, 06:48

We have that code at USER_LEAVE_ROOM event

Code: Select all

if (npcCount > 0 && realPlayerCount <= 0) {
                        RoomVariable updateGS = new SFSRoomVariable(ReservedRoomVariables.RV_GAME_STARTED, false);
                        updateGS.setGlobal(true);
                        getApi().setRoomVariables(user, room, Arrays.asList(updateGS), true, true, false);
                        for (User npcUser : playerList) {
                            if (npcUser.getName().contains("_R")) {
                                getApi().disconnectUser(npcUser);
                            }
                        }
                        return;


and also we have extension to kick out or disconnect users. we tried to remove from the game when they stuck in the game but it did not solve our problem when users stuck there we could not kick the users out. It also did not occur on our test environment so we write debug extension put on the live Smartfox server those methods were the only way to remove them from the game. Since then we have been using that code.

Also what stuck room represent is that there is a room that we can not delete with SFSApi.removeRoom(...) method and there is no either npc user nor normal user in it. We can not catch this kind of things with our test environment so we come up with these kind of weird solutions.

I will apply your suggestions though .

Thanks
User avatar
ekrem5353
Posts: 98
Joined: 10 Dec 2015, 15:50

Re: Some game rooms dont show up in smartfox Zone monitor

Postby ekrem5353 » 25 Nov 2019, 06:55

And also in these case, those methods were not get called there is trace before these methods.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 18 guests