Extension Server receive wrong order data!

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

Moderators: Lapo, Bax

wakawa2003
Posts: 14
Joined: 03 May 2019, 15:04

Extension Server receive wrong order data!

Postby wakawa2003 » 13 Jun 2019, 16:55

I take some test with Extension:
i send some text to extension in a cmd:
....
sfs.Send(new ExtensionRequest("cmd", data, sfs.LastJoinedRoom)); //with data is string=" Text 1 "
sfs.Send(new ExtensionRequest("cmd", data, sfs.LastJoinedRoom)); //with data is string=" Text 2 "
sfs.Send(new ExtensionRequest("cmd", data, sfs.LastJoinedRoom)); //with data is string=" Text 3 "
sfs.Send(new ExtensionRequest("cmd", data, sfs.LastJoinedRoom)); //with data is string=" Text 4 "
...
but in server side i got something like this with trace():
....
Text 4
Text 2
Text 1
Text 3
...
or something randomly.

How can i get true order ? Text 1 .. 2.. 3.. 4
thank you! :(
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extension Server receive wrong order data!

Postby Lapo » 14 Jun 2019, 08:17

Hi,
this depends on how threads process the client request. Requests are parked into a queue and then multiple threads pick one request and execute it. If 4 requests (from the same client) arrive at the same time at the server they might get executed out of order.

This however doesn't sound like a realistic use case. You don't normally send 4 requests one after the other like that. It would be the equivalent of sending them as one single request.

When you send very fast request (like an action real-time game) you still have have a 16-33ms pause between every client update, so requests will not get to the server at the same time and will continue to be processed in order. Plus, in a 60pps game you will need to use UDP which doesn't guarantee packet ordering anyway.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
wakawa2003
Posts: 14
Joined: 03 May 2019, 15:04

Re: Extension Server receive wrong order data!

Postby wakawa2003 » 14 Jun 2019, 12:09

Thank you. i'm resolved my problem....
And i have a new question:
When i'm use (in Unity)

Code: Select all


        // Set connection parameters
        ConfigData cfg = new ConfigData();
        cfg.Host = host;// 127.0.0.1
        cfg.Port = port;//9933
        cfg.Zone = zone;
        cfg.UdpHost = hostUDP;//127.0.0.1 or 0.0.0.0
        cfg.UdpPort = portUDP;//9933
        cfg.UseBlueBox = false;
        // Connect to SFS2X
        sfs.Connect(cfg);
......
and use:
  sfs.Send(new ExtensionRequest("test", sFSObject, sfs.LastJoinedRoom,true)
  ....
 

And i get some error in unity editor:

Code: Select all

NullReferenceException: Object reference not set to an instance of an object
Sfs2X.Bitswarm.BitSwarmClient.NextUdpPacketId () (at <553c914a816344c0974b4c471ec52cc5>:0)
Sfs2X.Core.SFSProtocolCodec.PrepareUDPPacket (Sfs2X.Bitswarm.IMessage message) (at <553c914a816344c0974b4c471ec52cc5>:0)
Sfs2X.Core.SFSProtocolCodec.OnPacketWrite (Sfs2X.Bitswarm.IMessage message) (at <553c914a816344c0974b4c471ec52cc5>:0)
Sfs2X.Bitswarm.BitSwarmClient.Send (Sfs2X.Bitswarm.IMessage message) (at <553c914a816344c0974b4c471ec52cc5>:0)
Sfs2X.SmartFox.Send (Sfs2X.Requests.IRequest request) (at <553c914a816344c0974b4c471ec52cc5>:0)
CharacterMove.Send () (at Assets/Scripts/CharacterMove.cs:71)
CharacterMove.Update () (at Assets/Scripts/CharacterMove.cs:56)

What is missing in my case?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extension Server receive wrong order data!

Postby Lapo » 14 Jun 2019, 14:02

It's difficult to say because you're not showing the entire code or explaining the sequence of requests you're using.
You can send an Extension request only after you have logged in successfully.

Also there is an extra step if you plan to use UDP, you need to open a UDP channel after having logged in.
The sequence to get started is:
- Connect
- Log in
- Initialize UDP (via SmartFox.InitUdp)
- continue with whatever request you need.

If you're not entirely familiar with these basic steps I highly recommend taking a look at the basic tutorials in our docs, as they will guide you through all the steps:
http://docs2x.smartfoxserver.com/Exampl ... troduction

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
wakawa2003
Posts: 14
Joined: 03 May 2019, 15:04

Re: Extension Server receive wrong order data!

Postby wakawa2003 » 18 Jun 2019, 01:43

thank you!!!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 93 guests