asadm / playroom-unity

9 stars 1 forks source link

[Feature-Request]: onDisconnect(callback) #82

Closed SaadBazaz closed 2 weeks ago

SaadBazaz commented 2 weeks ago

What do you want to see?

A function similar more to onPlayerJoin than onQuit. Basically covers a bit of #76 .

Docs reference to upstream: https://docs.joinplayroom.com/apidocs#ondisconnectcallback

Link to original discussion

https://discord.com/channels/997752993598419044/1128151935669764096/1253190034815848509

momintlh commented 2 weeks ago

We already have a OnDisconnect(callback) implemented:

  public static void OnDisconnect(Action callback)
        {
            CallbackManager.RegisterCallback(callback);
            OnDisconnectInternal(onDisconnectCallbackHandler);
        }

JS Side::

 OnDisconnectInternal: function (callback) {
    if (!window.Playroom) {
      console.error(
        "Playroom library is not loaded. Please make sure to call InsertCoin first."
      );
      return;
    }

    Playroom.onDisconnect((e) => {
      console.log(`Disconnected!`, e.code, e.reason);
      dynCall("v", callback, []);
    });
  },
SaadBazaz commented 2 weeks ago

Got it; big confusion from my side. I'll close the issue and inform, then.