예제 #1
0
        public static void SendRpc(ushort objId, string method, object[] data, netvrkTargets targets, int channel = 0)
        {
            if (!isConnected)
            {
                Debug.LogWarning("netVRk: Can not send RPCs when not connected!");
                return;
            }
            int methodId = GetObjMethodId(objId, method);

            if (methodId < 0)
            {
                Debug.LogError("netVRk: Rpc method: " + method + " not found!");
                return;
            }

            byte[] bytes = netvrkSerialization.SerializeRpc(objId, (byte)methodId, data);
            for (int i = 0; i < playerList.Count; i++)
            {
                SteamNetworking.SendP2PPacket(playerList[i].SteamId, bytes, (uint)bytes.Length, EP2PSend.k_EP2PSendReliable, channel);
            }
            if (targets == netvrkTargets.All)
            {
                ObjData objData = objList[objId];
                objData.rpcMethods[methodId].Invoke(objData.scripts[methodId], data);
            }
        }
예제 #2
0
파일: netvrkView.cs 프로젝트: virror/netVRk
 public void Rpc(string method, netvrkTargets targets, int channel = 0, params object[] message)
 {
     netvrkManager.SendRpc(id, method, message, targets, channel);
 }