void SendChat(PhotonTargets target) { if (chatInput != "") { photonView.RPC("SendChatMessage", target, chatInput); chatInput = ""; } }
void DoREC() { // get the photon proxy for Photon RPC access GameObject go = GameObject.Find("PlayMaker Photon Proxy"); if (go == null) { return; } if (remoteEvent != null && remoteEvent.IsGlobal == false) { return; } PhotonTargets _photonTargets = getPhotonTargets(); // get the proxy component PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>(); if (_proxy == null) { return; } if (!stringData.IsNone && stringData.Value != "") { _proxy.PhotonRpcBroacastFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value); } else { _proxy.PhotonRpcBroacastFsmEvent(photonTargets, remoteEvent.Name); } }
/// <summary> /// A method to send a public chat message. /// </summary> /// <param name="targets"> /// The players to whom this message should be sent. /// </param> /// <param name="message"> /// The message to send. /// </param> public void SendChat(PhotonTargets targets, string message) { if (message != "") { photonView.RPC("AddMessage", targets, message); } }
/*Public methods*/ public void StartGame() { if (false == UseRoom) { //Create room with default settings and join it SimulationSettings.InitialBalance = this.InitialCompanyBalance; SimulationSettings.TargetBalance = this.TargetCompanyBalance; SimulationSettings.MinimalBalance = this.MinimalCompanyBalance; RoomOptions options = new RoomOptions() { MaxPlayers = MAX_NUMBER_OF_PLAYERS_PER_ROOM }; PhotonNetwork.JoinOrCreateRoom("Default", options, PhotonNetwork.lobby); } //Master client will wait for other clients until they are ready to receive data //then start game if (true == PhotonNetwork.isMasterClient) { PhotonNetwork.room.IsOpen = false; //In offline mode game will be started immediately PhotonTargets targets = PhotonNetwork.offlineMode ? PhotonTargets.All : PhotonTargets.Others; this.photonView.RPC("StartGameInternal", targets); } }
//public void RPCBroadcastInterceptor(PhotonTargets targets, CardVisual interceptor) { //} public void RPCBroadcastCombat(PhotonTargets targets, CardVisual attacker, CardVisual defender) { int attackerID = attacker.photonView.viewID; int defenderID = defender.photonView.viewID; owner.photonView.RPC("BroadcastCombat", targets, attackerID, defenderID); }
void SendChat(PhotonTargets target) { if (chatInput != "") { photonView.RPC("SendChatMessage", target, chatInput); chatInput = ""; } }
public IEnumerator RPCBroadcastTurnStart(PhotonTargets targets, Player player) { yield return(new WaitForSeconds(0.5f)); int playerID = player.photonView.viewID; photonView.RPC("BroadcastTurnStart", targets, playerID); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcastFsmEvent" that use RPC to send information about the event to Send to self over the network /// </summary> /// <param name='target'> /// Photon Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to send using the photon target rule. /// </param> public void PhotonRpcSendFsmEvent(PhotonTargets target,string globalEventName) { if (LogMessageInfo) { Debug.Log("RPC to send global Fsm Event:"+globalEventName+" to self, with network target:"+target.ToString()); } photonView.RPC("rpc", target, globalEventName);// method name used to be too long : "RPC_PhotonRpcBroadcastFsmEvent" }
} // sendPhotonInstantiationFsmEvent #endregion #region Photon RPC TARGETS /// <summary> /// Function typically called from the action "PhotonViewRpcBroadcastFsmEvent" that use RPC to send information about the event to Send to self over the network /// </summary> /// <param name='target'> /// Photon Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to send using the photon target rule. /// </param> public void PhotonRpcSendFsmEvent(PhotonTargets target, string globalEventName) { if (LogMessageInfo) { Debug.Log("RPC to send global Fsm Event:" + globalEventName + " to self, with network target:" + target.ToString()); } photonView.RPC("rpc", target, globalEventName); // method name used to be too long : "RPC_PhotonRpcBroadcastFsmEvent" }
/// <summary> /// Internal to send an RPC on given PhotonView. /// </summary> /// <param name="view">photonView</param> /// <param name="methodName">string methodName</param> /// <param name="target">PhotonTargets.?</param> /// <param name="encrypt">encrypt</param> /// <param name="parameters">params</param> public void SendRPC(string methodName, PhotonTargets target, params object[] parameters) { if (!photonView) { Debug.Log($"Can't send RPC to {target.ToString()} players because photonView is null"); return; } photonView.RPC(methodName, target, parameters); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcastFsmEvent" that use RPC to send information about the event to Send to self over the network /// </summary> /// <param name='target'> /// Photon Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast using the photon target rule. /// </param> /// <param name='stringData'> /// String data to pass with this event. WARNING: this is not supposed to be (nor efficient) a way to synchronize data. This is simply to comply with /// the ability for FsmEvent to include data. /// </param> public void PhotonRpcSendFsmEventWithString(PhotonTargets target,string globalEventName,string stringData) { if (LogMessageInfo) { Debug.Log("RPC to send string:"+stringData+" with global Fsm Event:"+globalEventName+" to self, with network target:"+target.ToString()); } photonView.RPC("rpc_s", target, globalEventName, stringData);// method name used to be too long : "RPC_FsmPhotonRpcBroadcastFsmEventWithString" }
void SendChat(PhotonTargets target) { if (chatInput != "") { string tempChat = " " + chatInput; photonView.RPC("SendChatMessage", target, tempChat, (string)PhotonNetwork.player.customProperties["TeamName"]); chatInput = ""; } }
/// <summary> /// Internal to send an RPC on given PhotonView. /// </summary> /// <param name="view">photonView</param> /// <param name="methodName">string methodName</param> /// <param name="target">PhotonTargets.?</param> /// <param name="encrypt">encrypt</param> /// <param name="parameters">params</param> public void Send(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { if (view == null) { Debug.Log($"Can't send RPC to {target.ToString()} players because photonView is null"); return; } view.RPC(methodName, target, encrypt, parameters); }
void DoREC() { // get the photon proxy for Photon RPC access GameObject go = GameObject.Find("PlayMaker Photon Proxy"); if (go == null) { return; } if (remoteEvent != null && remoteEvent.IsGlobal == false) { return; } PhotonTargets _photonTargets = getPhotonTargets(); // get the proxy component PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>(); if (_proxy == null) { Debug.LogWarning("PlayMakerPhotonProxy is missing"); return; } if (eventTarget.target == FsmEventTarget.EventTarget.BroadcastAll) { if (!stringData.IsNone && stringData.Value != "") { _proxy.PhotonRpcBroacastFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value); } else { _proxy.PhotonRpcBroacastFsmEvent(photonTargets, remoteEvent.Name); } } else { PlayMakerPhotonGameObjectProxy _goProxy = Owner.GetComponent <PlayMakerPhotonGameObjectProxy>(); if (_proxy == null) { Debug.LogWarning("PlayMakerPhotonProxy is missing"); return; } if (!stringData.IsNone && stringData.Value != "") { _goProxy.PhotonRpcSendFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value); } else { _goProxy.PhotonRpcSendFsmEvent(photonTargets, remoteEvent.Name); } } }
public void RPCTransferCard(PhotonTargets targets, CardVisual card, Deck targetLocation) { //Debug.Log(card.cardData.cardName + " is being sent from " + card.currentDeck.decktype.ToString() + " to " + targetLocation.decktype.ToString()); int cardID = card.photonView.viewID; int deckID = targetLocation.photonView.viewID; photonView.RPC("TransferCard", targets, cardID, deckID); }
public static void Centerprint(string message, PhotonTargets targets, string tag = "msg", Color color = new Color(), EWarningType type = EWarningType.E_NORMAL) { PLServer.Instance.photonView.RPC("AddCrewWarning", targets, new object[] { message, color, (int)type, tag }); }
/// <summary> /// Function typically called from the action "PhotonViewRpcBroadcastFsmEvent" that use RPC to send information about the event to Send to self over the network /// </summary> /// <param name='target'> /// Photon Target. /// </param> /// <param name='globalEventName'> /// Global Fsm event name to broadcast using the photon target rule. /// </param> /// <param name='stringData'> /// String data to pass with this event. WARNING: this is not supposed to be (nor efficient) a way to synchronize data. This is simply to comply with /// the ability for FsmEvent to include data. /// </param> public void PhotonRpcSendFsmEventWithString(PhotonTargets target, string globalEventName, string stringData) { if (LogMessageInfo) { Debug.Log("RPC to send string:" + stringData + " with global Fsm Event:" + globalEventName + " to self, with network target:" + target.ToString()); } photonView.RPC("rpc_s", target, globalEventName, stringData); // method name used to be too long : "RPC_FsmPhotonRpcBroadcastFsmEventWithString" }
void SendChat(PhotonTargets target) { if (chatInput != "") { string tempChat = " " + chatInput; photonView.RPC("SendChatMessage", target, tempChat); chatInput = ""; } }
public override void RPCCheckDeath(PhotonTargets targets, CardVisual source, bool forceDeath, bool waitForVFX) { int cardID = source.photonView.viewID; if (health < 0 && deathEffect != "") { Debug.Log(cardData.cardName + " is showing a death effect"); } photonView.RPC("CheckDeath", targets, cardID, forceDeath, waitForVFX); }
public void CallRPC(Action n, PhotonTargets m) { if (PhotonNetwork.connectionState != ConnectionState.Disconnected) { photonView.RPC(n.Method.Name, m); } else { n(); } }
public static void ChatMessage(PhotonTargets targets, string message, int sendingPlayerId = -1) { if (sendingPlayerId == -1) { sendingPlayerId = PLNetworkManager.Instance.LocalPlayerID; } PLServer.Instance.photonView.RPC("TeamMessage", targets, new object[] { message, sendingPlayerId }); }
public void CallRPC <T>(Action <T> n, PhotonTargets m, T p) { if (PhotonNetwork.connectionState != ConnectionState.Disconnected) { photonView.RPC(n.Method.Name, m, p); } else { n(p); } }
public void CallRPC <T, T2, T3>(Action <T, T2, T3> n, PhotonTargets m, T p, T2 p2, T3 p3) { if (PhotonNetwork.connectionState != ConnectionState.Disconnected) { photonView.RPC(n.Method.Name, m, p, p2, p3); } else { n(p, p2, p3); } }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { if (PhotonNetwork.networkingPeer.hasSwitchedMC && target == PhotonTargets.MasterClient) { PhotonNetwork.RPC(this, methodName, PhotonNetwork.masterClient, parameters); } else { PhotonNetwork.RPC(this, methodName, target, parameters); } }
public void CallRPC <T, T2, T3, T4, T5, T6>(Action <T, T2, T3, T4, T5, T6> n, PhotonTargets m, T p, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6) { if (PhotonNetwork.connectionState != ConnectionState.Disconnected) { photonView.RPC(n.Method.Name, m, p, p2, p3, p4, p5, p6); } else { n(p, p2, p3, p4, p5, p6); } }
public override void Reset() { // JFF: how can I set this silently without a plubic variable? if I set it to private, it doesn't work anymore. maybe I forgot a setting? eventTarget = new FsmEventTarget(); eventTarget.target = FsmEventTarget.EventTarget.BroadcastAll; remoteEvent = null; photonTargets = PhotonTargets.All; photonTargetsFromString = null; stringData = null; }
public override void Reset() { // JFF: how can I set this silently without a plubic variable? if I set it to private, it doesn't work anymore. maybe I forgot a setting? eventTarget = new FsmEventTarget(); eventTarget.target = FsmEventTarget.EventTarget.BroadcastAll; remoteEvent = null; photonTargets = PhotonTargets.All; photonTargetsFromString = null; stringData = null; }
public void RPCBeginDrawing(PhotonTargets targets, Vector3 sourcePos, Vector3 targetPos) { float xpos = sourcePos.x; float ypos = sourcePos.y; float zpos = sourcePos.z; float targetX = targetPos.x; float targetY = targetPos.y; float targetZ = targetPos.z; photonView.RPC("BeginDrawing", targets, xpos, ypos, zpos, targetX, targetY, targetZ); }
public static void Echo(PhotonTargets targets, string message) { if (message == null) { AntiNullReferenceException($"targets: {targets}, {(message == null ? "message: null" : $"message: \"{message}\"")}"); return; } PLServer.Instance.photonView.RPC("ConsoleMessage", targets, new object[] { message }); }
public static void Notification(string message, PhotonTargets targets, int subjectPlayerId = 0, int durationMs = 6000, bool addToShipLog = false) { if (PLServer.Instance == null) { Logger.Info($"Notification attempted and PLServer was null. Message: {message}"); } PLServer.Instance.photonView.RPC("AddNotification", targets, new object[] { message, subjectPlayerId, PLServer.Instance.GetEstimatedServerMs() + durationMs, addToShipLog }); }
// Token: 0x0600BE9A RID: 48794 RVA: 0x004587AE File Offset: 0x004569AE private void KDMKDEKCELE() { if (!base.IBKCMBIGOEJ().BGJKMGJBPFA()) { return; } PhotonView photonView = base.OELHGNKAMEG(); string lblkdnnpaco = "You must complete your map before submiting it to Workshop"; PhotonTargets mpnmoonbmii = PhotonTargets.All; object[] array = new object[0]; array[0] = 0; photonView.MIAHMDGOOPJ(lblkdnnpaco, mpnmoonbmii, array); }
// Token: 0x0600BE9B RID: 48795 RVA: 0x004587E1 File Offset: 0x004569E1 private void MKIMDFLBFOM() { if (!base.JAEJDHHCJJO().DOLKFPIABDD()) { return; } PhotonView photonView = base.GBMJAPGLMGB(); string lblkdnnpaco = "maps."; PhotonTargets mpnmoonbmii = PhotonTargets.All; object[] array = new object[0]; array[1] = 1; photonView.KEKKFNNMLMG(lblkdnnpaco, mpnmoonbmii, array); }
// Token: 0x0600BE92 RID: 48786 RVA: 0x00458672 File Offset: 0x00456872 private void NPLCENPNJBM() { if (!base.JAEJDHHCJJO().BGJKMGJBPFA()) { return; } PhotonView photonView = base.JAEJDHHCJJO(); string lblkdnnpaco = "_Offsets"; PhotonTargets mpnmoonbmii = PhotonTargets.All; object[] array = new object[0]; array[1] = 0; photonView.MIAHMDGOOPJ(lblkdnnpaco, mpnmoonbmii, array); }
// Token: 0x0600BE8F RID: 48783 RVA: 0x004585FE File Offset: 0x004567FE private void KLILJHJNICK() { if (!base.photonView.isMine) { return; } PhotonView photonView = base.ACPGHFHDCIP(); string lblkdnnpaco = "scn"; PhotonTargets mpnmoonbmii = PhotonTargets.Others; object[] array = new object[0]; array[1] = 1; photonView.PBMFBOOALKA(lblkdnnpaco, mpnmoonbmii, array); }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> ///<param name="methodName">The name of a fitting method that was has the RPC attribute.</param> ///<param name="target">The group of targets and the way the RPC gets sent.</param> ///<param name="encrypt"> </param> ///<param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RpcSecure(string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { PhotonNetwork.RPC(this, methodName, target, encrypt, parameters); }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { RpcSecure(methodName, target, false, parameters); }
/// RPC Hashtable Structure /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id) /// (byte)1 -> (short) prefix (level) /// (byte)2 -> (int) server timestamp /// (byte)3 -> (string) methodname /// (byte)4 -> (object[]) parameters /// (byte)5 -> (string) method shortcut (alternative to name) /// /// This is sent as event (code: 200) which will contain a sender (origin of this RPC). internal void RPC(PhotonView view, string methodName, PhotonTargets target, params object[] parameters) { if (this.blockSendingGroups.Contains(view.group)) { return; // Block sending on this group } if (view.viewID < 1) { Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name); } if (this.DebugOut >= DebugLevel.INFO) { this.DebugReturn(DebugLevel.INFO, "Sending RPC \"" + methodName + "\" to " + target); } //ts: changed RPCs to a one-level hashtable as described in internal.txt Hashtable rpcEvent = new Hashtable(); rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&PLAYERS if (view.prefix > 0) { rpcEvent[(byte)1] = (short)view.prefix; } rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds; // send name or shortcut (if available) int shortcut = 0; if (rpcShortcuts.TryGetValue(methodName, out shortcut)) { rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT } else { rpcEvent[(byte)3] = methodName; } if (parameters != null || parameters.Length == 0) { rpcEvent[(byte)4] = (object[])parameters; } // Check scoping if (target == PhotonTargets.All) { this.OpRaiseEvent(PhotonNetworkMessages.RPC, (byte)view.group, rpcEvent, true, 0); // Execute local this.ExecuteRPC(rpcEvent, this.mLocalActor); } else if (target == PhotonTargets.Others) { this.OpRaiseEvent(PhotonNetworkMessages.RPC, (byte)view.group, rpcEvent, true, 0); } else if (target == PhotonTargets.AllBuffered) { this.OpRaiseEvent(PhotonNetworkMessages.RPC, rpcEvent, true, 0, EventCaching.AddToRoomCache, ReceiverGroup.Others); // Execute local this.ExecuteRPC(rpcEvent, this.mLocalActor); } else if (target == PhotonTargets.OthersBuffered) { this.OpRaiseEvent(PhotonNetworkMessages.RPC, rpcEvent, true, 0, EventCaching.AddToRoomCache, ReceiverGroup.Others); } else if (target == PhotonTargets.MasterClient) { if (this.mMasterClient == this.mLocalActor) { this.ExecuteRPC(rpcEvent, this.mLocalActor); } else { this.OpRaiseEvent(PhotonNetworkMessages.RPC, rpcEvent, true, 0, EventCaching.DoNotCache, ReceiverGroup.MasterClient);//TS: changed from caching to non-cached. this goes to master only } } else { Debug.LogError("Unsupported target enum: " + target); } }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { PhotonNetwork.RPC(this, methodName, target, false, parameters); }
/// RPC Hashtable Structure /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id) /// (byte)1 -> (short) prefix (level) /// (byte)2 -> (int) server timestamp /// (byte)3 -> (string) methodname /// (byte)4 -> (object[]) parameters /// (byte)5 -> (byte) method shortcut (alternative to name) /// /// This is sent as event (code: 200) which will contain a sender (origin of this RPC). internal void RPC(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { // Check scoping if (target == PhotonTargets.All) { RPC(view, methodName, PhotonNetwork.playerList, encrypt, parameters); } else if (target == PhotonTargets.Others) { RPC(view, methodName, PhotonNetwork.otherPlayers, encrypt, parameters); } else if(target == PhotonTargets.MasterClient) { RPC(view, methodName, PhotonNetwork.masterClient, encrypt, parameters); } }
/// RPC Hashtable Structure /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id) /// (byte)1 -> (short) prefix (level) /// (byte)2 -> (int) server timestamp /// (byte)3 -> (string) methodname /// (byte)4 -> (object[]) parameters /// (byte)5 -> (byte) method shortcut (alternative to name) /// /// This is sent as event (code: 200) which will contain a sender (origin of this RPC). internal void RPC(PhotonView view, string methodName, PhotonTargets target, PhotonPlayer player, bool encrypt, params object[] parameters) { if (this.blockSendingGroups.Contains(view.group)) { return; // Block sending on this group } if (view.viewID < 1) { Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name); } if (PhotonNetwork.logLevel >= PhotonLogLevel.Full) { Debug.Log("Sending RPC \"" + methodName + "\" to target: " + target + " or player:" + player + "."); } //ts: changed RPCs to a one-level hashtable as described in internal.txt Hashtable rpcEvent = new Hashtable(); rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&PLAYERS if (view.prefix > 0) { rpcEvent[(byte)1] = (short)view.prefix; } rpcEvent[(byte)2] = PhotonNetwork.ServerTimestamp; // send name or shortcut (if available) int shortcut = 0; if (rpcShortcuts.TryGetValue(methodName, out shortcut)) { rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT } else { rpcEvent[(byte)3] = methodName; } if (parameters != null && parameters.Length > 0) { rpcEvent[(byte)4] = (object[])parameters; } // if sent to target player, this overrides the target if (player != null) { if (this.LocalPlayer.ID == player.ID) { this.ExecuteRpc(rpcEvent, player); } else { RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { player.ID }, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } return; } // send to a specific set of players if (target == PhotonTargets.All) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); // Execute local this.ExecuteRpc(rpcEvent, this.LocalPlayer); } else if (target == PhotonTargets.Others) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } else if (target == PhotonTargets.AllBuffered) { RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); // Execute local this.ExecuteRpc(rpcEvent, this.LocalPlayer); } else if (target == PhotonTargets.OthersBuffered) { RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } else if (target == PhotonTargets.MasterClient) { if (this.mMasterClientId == this.LocalPlayer.ID) { this.ExecuteRpc(rpcEvent, this.LocalPlayer); } else { RaiseEventOptions options = new RaiseEventOptions() { Receivers = ReceiverGroup.MasterClient, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } } else if (target == PhotonTargets.AllViaServer) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); if (PhotonNetwork.offlineMode) { this.ExecuteRpc(rpcEvent, this.LocalPlayer); } } else if (target == PhotonTargets.AllBufferedViaServer) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All, CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); if (PhotonNetwork.offlineMode) { this.ExecuteRpc(rpcEvent, this.LocalPlayer); } } else { Debug.LogError("Unsupported target enum: " + target); } }
void resetDoorTime(PhotonTargets ptarget) { photonView.RPC("resetDoors",ptarget, false); }
private void SendChat(PhotonTargets target) { Debug.Log(target); photonView.RPC("SendChatMessage", target, chatInput); chatInput = ""; }
void SendChat(PhotonTargets target) { if (chatInput != "") { //Send to other players if (photonView) photonView.RPC("SendChatMessage", target, "<"+chatterClass+">: " +chatInput, chatterClass); //Send to online database StartCoroutine(saveChatToOnlineDatabase()); //Empty input chatInput = ""; } }
/// <summary> /// Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client). /// </summary> /// <remarks> /// [Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. /// It enables you to make every client in a room call a specific method. /// /// RPC calls can target "All" or the "Others". /// Usually, the target "All" gets executed locally immediately after sending the RPC. /// The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. /// Of course, calls are affected by this client's lag and that of remote clients. /// /// Each call automatically is routed to the same PhotonView (and GameObject) that was used on the /// originating client. /// /// See: [Remote Procedure Calls](@ref rpcManual). /// </remarks> /// <param name="methodName">The name of a fitting method that was has the RPC attribute.</param> /// <param name="target">The group of targets and the way the RPC gets sent.</param> /// <param name="parameters">The parameters that the RPC method has (must fit this call!).</param> public void RPC(string methodName, PhotonTargets target, params object[] parameters) { if(PhotonNetwork.networkingPeer.hasSwitchedMC && target == PhotonTargets.MasterClient) { PhotonNetwork.RPC(this, methodName, PhotonNetwork.masterClient, parameters); } else { PhotonNetwork.RPC(this, methodName, target, parameters); } }
/// <summary> /// Internal to send an RPC on given PhotonView. Do not call this directly but use: PhotonView.RPC! /// </summary> internal static void RPC(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { if (!VerifyCanUseNetwork()) { return; } if (room == null) { Debug.LogWarning("RPCs can only be sent in rooms. Call of \"" + methodName + "\" gets executed locally only, if at all."); return; } if (networkingPeer != null) { if (PhotonNetwork.room.serverSideMasterClient) { networkingPeer.RPC(view, methodName, target, null, encrypt, parameters); } else { if (PhotonNetwork.networkingPeer.hasSwitchedMC && target == PhotonTargets.MasterClient) { networkingPeer.RPC(view, methodName, PhotonTargets.Others, PhotonNetwork.masterClient, encrypt, parameters); } else { networkingPeer.RPC(view, methodName, target, null, encrypt, parameters); } } } else { Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?"); } }
public static void RpcSecureAsMaster(this PhotonView photonView, string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { RpcManager.SendRpcSecureToMaster(photonView, methodName, target, encrypt, parameters); }
/// <summary> /// Internal to send an RPC on given PhotonView. Do not call this directly but use: PhotonView.RPC! /// </summary> internal static void RPC(PhotonView view, string methodName, PhotonTargets target, bool encrypt, params object[] parameters) { if (!VerifyCanUseNetwork()) { return; } if (room == null) { Debug.LogWarning("Cannot send RPCs in Lobby! RPC dropped."); return; } if (networkingPeer != null) { if (PhotonNetwork.networkingPeer.hasSwitchedMC && target == PhotonTargets.MasterClient) { networkingPeer.RPC(view, methodName, PhotonNetwork.masterClient, encrypt, parameters); } else { networkingPeer.RPC(view, methodName, target, encrypt, parameters); } } else { Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?"); } }
/// <summary> /// Internal to send an RPC on given PhotonView. Do not call this directly but use: PhotonView.RPC! /// </summary> internal static void RPC(PhotonView view, string methodName, PhotonTargets target, params object[] parameters) { if (!VerifyCanUseNetwork()) { return; } if (room == null) { UnityEngine.Debug.LogWarning("Cannot send RPCs in Lobby! RPC dropped."); return; } if (networkingPeer != null) { networkingPeer.RPC(view, methodName, target, parameters); } else { UnityEngine.Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?"); } }
/// RPC Hashtable Structure /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id) /// (byte)1 -> (short) prefix (level) /// (byte)2 -> (int) server timestamp /// (byte)3 -> (string) methodname /// (byte)4 -> (object[]) parameters /// (byte)5 -> (byte) method shortcut (alternative to name) /// /// This is sent as event (code: 200) which will contain a sender (origin of this RPC). internal void RPC(PhotonView view, string methodName, PhotonTargets target, params object[] parameters) { if (this.blockSendingGroups.Contains(view.group)) { return; // Block sending on this group } if (view.viewID < 1) { Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name); } if (PhotonNetwork.logLevel >= PhotonLogLevel.Full) Debug.Log("Sending RPC \"" + methodName + "\" to " + target); //ts: changed RPCs to a one-level hashtable as described in internal.txt Hashtable rpcEvent = new Hashtable(); rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&PLAYERS if (view.prefix > 0) { rpcEvent[(byte)1] = (short)view.prefix; } rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds; // send name or shortcut (if available) int shortcut = 0; if (rpcShortcuts.TryGetValue(methodName, out shortcut)) { rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT } else { rpcEvent[(byte)3] = methodName; } if (parameters != null && parameters.Length > 0) { rpcEvent[(byte)4] = (object[])parameters; } // Check scoping if (target == PhotonTargets.All) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); //this.OpRaiseEvent(PunEvent.RPC, (byte)view.group, rpcEvent, true, 0); // Execute local this.ExecuteRPC(rpcEvent, this.mLocalActor); } else if (target == PhotonTargets.Others) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } else if (target == PhotonTargets.AllBuffered) { RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache}; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); // Execute local this.ExecuteRPC(rpcEvent, this.mLocalActor); } else if (target == PhotonTargets.OthersBuffered) { RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } else if (target == PhotonTargets.MasterClient) { if (this.mMasterClient == this.mLocalActor) { this.ExecuteRPC(rpcEvent, this.mLocalActor); } else { RaiseEventOptions options = new RaiseEventOptions() { Receivers = ReceiverGroup.MasterClient }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); } } else if (target == PhotonTargets.AllViaServer) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); if (PhotonNetwork.offlineMode) { this.ExecuteRPC(rpcEvent, this.mLocalActor); } } else if (target == PhotonTargets.AllBufferedViaServer) { RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All, CachingOption = EventCaching.AddToRoomCache }; this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options); if (PhotonNetwork.offlineMode) { this.ExecuteRPC(rpcEvent, this.mLocalActor); } } else { Debug.LogError("Unsupported target enum: " + target); } }
void sendLiftTime(PhotonTargets ptarget) { photonView.RPC("updateLiftTime", ptarget, localLiftTime); }