Giter Club home page Giter Club logo

Comments (3)

Faless avatar Faless commented on May 18, 2024

I did some tests, and I was able to reproduce in some cases (although not reliably).
Is is possible that the state is actually sent, but instead the other client has not yet completed its join?
To explain further, take this timed sequence:

  1. Socket 1 receives matched event
  2. Socket 2 receives matched event
  3. Socket 1 ask to join
  4. Socket 2 ask to join
  5. Socket 1 join complete (it is now participating in the match)
  6. Socket 1 send the state (but socket 2 is not yet participating)
  7. Socket 2 join complete (it is now participating in the match)
  8. Socket 2 send the state (socket 1 is participating, so it receives the sent state)

When events happen in this order, socket 2 will not receive the state from socket 1 since when it was sent, socket 2 join had yet to complete.

Can you confirm from your server log that the message is not actually sent? Or is it just not received from the other client? Can you provide a server log when this happen?

See my log for when I'm able to reproduce:

nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.432Z","msg":"Sending *rtapi.Envelope_Match message","uid":"b48e37c2-120c-4b47-9690-c05adb6a1ca4","sid":"b578c46d-98c3-407e-828c-4be170875299","envelope":"cid:\"2\" match:<match_id:\"1f301c43-e474-423a-9fa7-953efad009c5.\" self:<user_id:\"b48e37c2-120c-4b47-9690-c05adb6a1ca4\" session_id:\"b578c46d-98c3-407e-828c-4be170875299\" username:\"QtWAlPPMeT\" > > "}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.432Z","msg":"Processing presence event","joins":1,"leaves":0}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.439Z","msg":"Received *rtapi.Envelope_MatchDataSend message","uid":"b48e37c2-120c-4b47-9690-c05adb6a1ca4","sid":"b578c46d-98c3-407e-828c-4be170875299","cid":"3","message":{"MatchDataSend":{"match_id":"1f301c43-e474-423a-9fa7-953efad009c5.","op_code":1,"data":"eyJhIjoxfQ=="}}}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.442Z","msg":"Received *rtapi.Envelope_MatchJoin message","uid":"b48e37c2-120c-4b47-9690-c05adb6a1ca4","sid":"ec0057c7-0a2d-40e3-be4b-23a4d5a653db","cid":"2","message":{"MatchJoin":{"Id":{"Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODkyNzg3MzksIm1pZCI6IjFmMzAxYzQzLWU0NzQtNDIzYS05ZmE3LTk1M2VmYWQwMDljNS4ifQ.-Ckhfc_Pr2Jjdi-rR6jQeqOXXqwcvsL3QKXelTXsE2I"}}}}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.442Z","msg":"Processing presence event","joins":1,"leaves":0}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.442Z","msg":"Sending *rtapi.Envelope_Match message","uid":"b48e37c2-120c-4b47-9690-c05adb6a1ca4","sid":"ec0057c7-0a2d-40e3-be4b-23a4d5a653db","envelope":"cid:\"2\" match:<match_id:\"1f301c43-e474-423a-9fa7-953efad009c5.\" size:1 presences:<user_id:\"b48e37c2-120c-4b47-9690-c05adb6a1ca4\" session_id:\"b578c46d-98c3-407e-828c-4be170875299\" username:\"QtWAlPPMeT\" > self:<user_id:\"b48e37c2-120c-4b47-9690-c05adb6a1ca4\" session_id:\"ec0057c7-0a2d-40e3-be4b-23a4d5a653db\" username:\"QtWAlPPMeT\" > > "}
nakama         | {"level":"debug","ts":"2020-05-12T10:18:29.445Z","msg":"Received *rtapi.Envelope_MatchDataSend message","uid":"b48e37c2-120c-4b47-9690-c05adb6a1ca4","sid":"ec0057c7-0a2d-40e3-be4b-23a4d5a653db","cid":"3","message":{"MatchDataSend":{"match_id":"1f301c43-e474-423a-9fa7-953efad009c5.","op_code":1,"data":"eyJhIjoxfQ=="}}}

As you can see the server receives Envelope_MatchDataSend from the first client before the Envelope_MatchJoin from the second client.

from nakama-godot.

reasv avatar reasv commented on May 18, 2024

Is is possible that the state is actually sent, but instead the other client has not yet completed its join?

Yes, there does seem to be a race condition here, I enabled debug output and the message is received before the second client has joined, the reason why this doesn't seem to happen with two desktop clients is probably that they take the same amount of time to join.

In hindsight it's obvious that after join_matched_async() returns it's not guaranteed that everyone joined, but I didn't think of that at first.

I guess there's no problem with the API then.

from nakama-godot.

Faless avatar Faless commented on May 18, 2024

I'll close the issue then.
Keep in mind that you can probably use the received_match_presence event (along with the presences in the Match object returned by the join) to know when everybody has connected.

from nakama-godot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.