Some USER_VARIABLES_UPDATE event are not received

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Termway
Posts: 1
Joined: 03 Oct 2022, 12:59

Some USER_VARIABLES_UPDATE event are not received

Postby Termway » 03 Oct 2022, 13:24

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()}");
    // ...   
}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Some USER_VARIABLES_UPDATE event are not received

Postby Lapo » 04 Oct 2022, 07:36

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
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 26 guests