SetUserVariablesRequest never comes to server

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

Moderators: Lapo, Bax

NickNick
Posts: 6
Joined: 13 Jul 2017, 09:30

SetUserVariablesRequest never comes to server

Postby NickNick » 13 Jul 2017, 09:42

Using Unity client.
I'm trying to add some info about users in the room in the simplest possible way - with user variables (don't even really need to change it afterwards).
First of all, login extension is configured and working, so users get Standard profile ID (checked in admin tool).
Now I'm trying to submit request like this

Code: Select all

private void OnAuthentication(BaseEvent evt)
        {
...
            Sfs.Send(new SetUserVariablesRequest(variables)); //really just a single SFSObject variable in list
...
        }


And that row does fire, but nothing happens after - no USER_VARIABLES_UPDATE event, no Runtime variables in admin tool, even added something like this as server extension

Code: Select all

public class CfsUserVariablesUpdate extends BaseServerEventHandler {

   @Override
   public void handleServerEvent(ISFSEvent arg0) throws SFSException {
      throw new SFSException("DEBUG!");
   }

}


and the are still no errors, like no information at all about what's happening.

Please any suggestions, thoughts, just anything.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SetUserVariablesRequest never comes to server

Postby Lapo » 13 Jul 2017, 13:43

Hi,
first thing first, check the server logs. Maybe there's an error related to your request.

The server side class/handler you have posted, is it added as handler for SFSEventType.USER_VARIABLES_UPDATE in the init() of your Extension?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
NickNick
Posts: 6
Joined: 13 Jul 2017, 09:30

Re: SetUserVariablesRequest never comes to server

Postby NickNick » 13 Jul 2017, 13:59

Thank you for the reply.

I'm using simple standalone server, so log mean console log? No errors there, and no error in any file in logs folder either.

Code: Select all

14:32:38,726 INFO  [main] v3.SessionFilter     - BlueBox-2X Service (3.1.0) READY.
14:32:42,923 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:1749 } on Server port: 9933 <---> 1749
14:32:43,010 INFO  [SFSWorker:Ext:4] api.SFSApi     - User login: { Zone: Steam}, ( User Name: MA_NAME_IS_JHONNY, Id: 0, Priv: 1, Sess: 127.0.0.1:1749 ) , Type: Unity
14:32:45,665 INFO  [SFSWorker:Sys:3] managers.SFSRoomManager     - Room created: { Zone: Steam }, [ Room: Jhonny's rroom, Id: 2, Group: default, isGame: false ], type = SFSRoom

After that I can check the room users in admin tool and that there no Runtime user variables, but they must be there. Btw also tried to SetUserVariablesRequest after joining room with no effect.

Simplest extension ever:

Code: Select all

public class ExtensionsConfig extends SFSExtension {

   @Override
   public void init() {
      addEventHandler(SFSEventType.ROOM_ADDED, CsfRoomAddedHandler.class); //Make all room variables global, cause why on the Earth are they not by default?!
      addEventHandler(SFSEventType.USER_LOGIN, CfsUserLoginHandler.class); // Adding profile to the session
      addEventHandler(SFSEventType.USER_JOIN_ZONE, CfsUserZoneJoinHandler.class); //Nothing here
      addEventHandler(SFSEventType.USER_VARIABLES_UPDATE, CfsUserVariablesUpdate.class); //Throw an exception - never happens
   }
}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SetUserVariablesRequest never comes to server

Postby Lapo » 13 Jul 2017, 15:35

NickNick wrote:Thank you for the reply.
I'm using simple standalone server, so log mean console log? No errors there, and no error in any file in logs folder either.

Yes, console log.
Okay no errors, good.

After that I can check the room users in admin tool and that there no Runtime user variables, but they must be there.

If the Admin says "no UserVars", you can trust it. There are no Uservars. The problem is somewhere else.

Btw also tried to SetUserVariablesRequest after joining room with no effect.

Yeah, doesn't matter.

Simplest extension ever:
//Make all room variables global, cause why on the Earth are they not by default?!

Because they can they must be transmitted to ALL users. So they are bandwidth demanding :wink: Non global RoomVars need only to be synchronized inside the Room. Much less resources required.

Back to your question/problem. What you're trying to do is pretty elementary and you should find no problem whatsoever but I'd like to see the whole code, from connection to creation of those variables.

If you prefer to keep this private, send us an email to our support@... email box with a reference to this thread. Otherwise just post it here.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
NickNick
Posts: 6
Joined: 13 Jul 2017, 09:30

Re: SetUserVariablesRequest never comes to server

Postby NickNick » 14 Jul 2017, 06:26

Ok, I've found the actual reason.

Code: Select all

private void OnJoinLobby(BaseEvent evt)
        {
            State = ClientState.JoinedLobby;
         
            DefaultSFSDataSerializer.RunningAssembly = Assembly.GetExecutingAssembly();
            var userSettings = new SFSObject();
            userSettings.PutInt("1", 123);
            userSettings.PutInt("2", 12345);
            userSettings.PutClass("3", new dto()); // <- if I remove this everything works fine
            var settingsVar = new SFSUserVariable("1", userSettings, (int)VariableType.OBJECT);
            settingsVar.IsPrivate = false;
            var variables =  new List<UserVariable> { (UserVariable) settingsVar };
            Sfs.MySelf.SetVariables(variables);
            Sfs.Send(new SetUserVariablesRequest(variables));
        }

See the comments on userSettings.PutClass("3", new dto());
dto is the simplest class possible

Code: Select all

public class dto
    {
        int val = 1;
    }


I've also added log listener like Sfs.AddLogListener(Sfs2X.Logging.LogLevel.ERROR, OnInternalError) but it doesn't fire.
So is there any way to at least catch such error? What am I missing?

Code: Select all

Sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            Sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            Sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            Sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            Sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE, OnJoinLobby);
            Sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate);
            Sfs.AddEventListener(SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, OnJoinLobbyError);

            Sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);
            Sfs.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomRemoved);
            Sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomAddError);
            Sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            Sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);

            Sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            Sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
            Sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
            Sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);

            Sfs.AddEventListener(SFSEvent.SOCKET_ERROR, OnSocketError);

            Sfs.AddLogListener(Sfs2X.Logging.LogLevel.ERROR, OnInternalError);
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SetUserVariablesRequest never comes to server

Postby Lapo » 14 Jul 2017, 08:02

I see two problems here:

1) dto class doesn't implement the SerializableSFSType interface, which is required
2) By setting the log level to ERROR you are filtering out all warnings, including the one telling you about the problem at #1 :)

For more: http://docs2x.smartfoxserver.com/Advanc ... ialization

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
NickNick
Posts: 6
Joined: 13 Jul 2017, 09:30

Re: SetUserVariablesRequest never comes to server

Postby NickNick » 14 Jul 2017, 08:41

Ok, thank you, that really helped and explained everything.

Pleas consider adding information about required interface in GetClass documentation http://docs2x.smartfoxserver.com/api-docs/csharp-doc/html/a5b96a70-fd94-c101-f0fc-0d528d57b3d9.htm, since I've just followed that example and it was kinda frustrating.

And also please at least discuss moving serialization errors to errors, not warnings.

Well, that's it, thank you again, problem is understood and solved now.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SetUserVariablesRequest never comes to server

Postby Lapo » 14 Jul 2017, 09:12

Oh yes, thanks for spotting the issue in the docs. We'll fix it right away.

As regards the logging, I would not recommend filtering out WARN level messages in any case. There are a lot of them and are usually useful to understand what went wrong.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SetUserVariablesRequest never comes to server

Postby Lapo » 14 Jul 2017, 09:22

Correction: the interface is called SerializableSFSType (fixed also in prev post)
I went by memory and should've checked.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 79 guests