asadm / playroom-unity

9 stars 1 forks source link

RPC registration gets overridden when another RPC is added #59

Closed SaadBazaz closed 2 months ago

SaadBazaz commented 2 months ago

What happened?

if I register 2 RPCs on 2 names like

RpcRegister("one", MethodOne);
RpcRegister("two", MethodTwo);

And I try to call the first one

RpcCall("one",null ,RpcMode.ALL, () => { Debug.Log("Called RPC One"); });

MethodTwo will be called instead of MethodOne, even though I RpcCalled "one"

I think this happens because in PlayroomKit.cs

private static Action<string, string> RpcRegisterCallback = null;

[DllImport("__Internal")]
private extern static void RpcRegisterInternal(string name, Action<string, string> rpcRegisterCallback, string onResponseReturn = null);

public static void RpcRegister(string name, Action<string, string> rpcRegisterCallback, string onResponseReturn = null)
{
    RpcRegisterCallback = rpcRegisterCallback;
    RpcRegisterInternal(name, InvokeRpcRegisterCallBack, onResponseReturn);
}

RpcRegisterCallback is just one Action that gets overridden whenever you register another RPC

Version

Unknown

What is your environment?

No response

Link to original discussion

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

Relevant log output

No response

SaadBazaz commented 2 months ago

Closing as resolved in #60