private RpcManager() { this.asyncRpcIndex = 0; QueuedRpcs = new Dictionary <Player, Queue <QueuedRpc> >(); registeredRPCs = new Dictionary <string, List <RegisteredRpc> >(); registeredAsyncRPCs = new Dictionary <string, List <RegisteredRpc> >(); RootElement.OnMiscelaniousEvent += (eventName, source, p1, p2, p3, p4, p5, p6, p7, p8) => { if (registeredRPCs.ContainsKey(eventName)) { Player player = ElementManager.Instance.GetElement <Player>(source); var registeredRpcs = registeredRPCs[eventName]; foreach (var registeredRpc in registeredRpcs) { var method = registeredRpc.callback; IRpc rpc = (IRpc)Activator.CreateInstance(registeredRpc.type); rpc.Parse(p1); method.Invoke(player, rpc); } } else if (registeredAsyncRPCs.ContainsKey(eventName)) { Player player = ElementManager.Instance.GetElement <Player>(source); var registeredRpcs = registeredAsyncRPCs[eventName]; foreach (var registeredRpc in registeredRpcs) { var method = registeredRpc.callback; AsyncRpc asyncRpc = Activator.CreateInstance <AsyncRpc>(); asyncRpc.Parse(p1); method.Invoke(player, asyncRpc); } } }; RegisterRPC <EmptyRpc>("slipe-client-ready-rpc", (player, rpc) => { if (QueuedRpcs.TryGetValue(player, out Queue <QueuedRpc> rpcQueue)) { player.IsReadyForIncomingRequests = true; QueuedRpcs.Remove(player); while (rpcQueue.TryDequeue(out QueuedRpc queuedRpc)) { if (queuedRpc.bandwidth != -1) { TriggerLatentRPC(player, queuedRpc.key, queuedRpc.bandwidth, queuedRpc.rpc, queuedRpc.persists); } else { TriggerRPC(player, queuedRpc.key, queuedRpc.rpc); } } }
private RpcManager() { this.asyncRpcIndex = 0; registeredRPCs = new Dictionary <string, List <RegisteredRpc> >(); registeredAsyncRPCs = new Dictionary <string, List <RegisteredRpc> >(); RootElement.OnMiscelaniousEvent += (eventName, source, p1, p2, p3, p4, p5, p6, p7, p8) => { if (registeredRPCs.ContainsKey(eventName)) { var registeredRpcs = registeredRPCs[eventName]; foreach (var registeredRpc in registeredRpcs) { var method = registeredRpc.callback; IRpc rpc = (IRpc)Activator.CreateInstance(registeredRpc.type); rpc.Parse(p1); method.Invoke(rpc); } } else if (registeredAsyncRPCs.ContainsKey(eventName)) { var registeredRpcs = registeredAsyncRPCs[eventName]; foreach (var registeredRpc in registeredRpcs) { var method = registeredRpc.callback; AsyncRpc asyncRpc = Activator.CreateInstance <AsyncRpc>(); asyncRpc.Parse(p1); method.Invoke(asyncRpc); } } }; }