NetworkingPeer.RPC C# (CSharp) Method

RPC() private method

private RPC ( PhotonView, view, string methodName, PhotonPlayer, player, bool encrypt ) : void
view PhotonView,
methodName string
player PhotonPlayer,
encrypt bool
return void
    internal void RPC(PhotonView view, string methodName, PhotonPlayer player, bool encrypt, params object[] parameters)
    {
        if (this.blockSendingGroups.Contains(view.group))
        {
            return; // Block sending on this group
        }

        if (view.viewID < 1)    //TODO: check why 0 should be illegal
        {
            Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
        }

        if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
        {
            Debug.Log("Sending RPC \"" + methodName + "\" to 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 PHOTONVIEWS&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;
        }

        if (this.mLocalActor == player)
        {
            this.ExecuteRpc(rpcEvent, player);
        }
        else
        {
            RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { player.ID }, Encrypt = encrypt };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
        }
    }

Same methods

NetworkingPeer::RPC ( PhotonView, view, string methodName, PhotonTargets target, bool encrypt ) : void

Usage Example

Exemplo n.º 1
0
 internal static void RPC(string methodName, PhotonPlayer targetPlayer, params object[] parameters)
 {
     if (VerifyCanUseNetwork())
     {
         if (room == null)
         {
             Debug.LogWarning("Cannot send RPCs in Lobby, only processed locally");
         }
         else
         {
             if (player == null)
             {
                 Debug.LogError("Error; Sending RPC to player null! Aborted \"" + methodName + "\"");
             }
             if (networkingPeer != null)
             {
                 networkingPeer.RPC(methodName, targetPlayer, parameters);
             }
             else
             {
                 Debug.LogWarning("Could not execute RPC " + methodName + ". Possible scene loading in progress?");
             }
         }
     }
 }
All Usage Examples Of NetworkingPeer::RPC
NetworkingPeer