Page 1 of 1

Some USER_VARIABLES_UPDATE event are not received

Posted: 03 Oct 2022, 13:24
by Termway
Hello there,

Is this normal that some SetUserVariablesRequest are dropped via a USER_VARIABLES_UPDATE event?

Currently, I'm only testing with one connected player and I send user variables update every frame but sometime I do not receive the update every frame nor do I receive the correct information in the missing event.

For example In the attachment image, I do not receive the values of user variables for the frame 792.
Is this expected behavior? How can I know that some event are dropped?

The code that created and send the request for the user variables (>> log)

Code: Select all

private void Update()
{
    //...
    _connection.SmartFox.Send(new SetUserVariablesRequest(_userVariables));
            
    Debug.Log($">> [{Time.frameCount}] {Time.realtimeSinceStartup} " + string.Join(", ", _userVariables));
    _connection.SmartFox.ProcessEvents();
}
The code that receive the user variable update. (<< log)

Code: Select all

public void OnUserVariableUpdate(Sfs2X.Core.BaseEvent evt)
{
    Debug.Log($"<< [{Time.frameCount}:{Time.realtimeSinceStartup}] {evt.Dump()}");
    // ...   
}

Re: Some USER_VARIABLES_UPDATE event are not received

Posted: 04 Oct 2022, 07:36
by Lapo
Hi,
updating variables every frame is likely an issue. User and Room vars are sent over TCP and there's a limit of 20-25 pps (packets per second) after which you will likely incur in packet drops (although in a local network it can go much higher than that).

Depending on the game you're developing you may need to switch to updates via UDP, or you just need to set a reasonable TCP packet rate that doesn't overwhelm the client.

For example our SpaceWar demo game uses standard UserVars over TCP and a packet rate of ~25pps.
You can take a look here:
http://docs2x.smartfoxserver.com/Exampl ... acewar2-p1

Cheers