/// <summary> /// Sends the RPC. /// </summary> /// <param name="stream">The stream.</param> /// <param name="target">The target.</param> /// <param name="caller">The caller.</param> /// <param name="rpcMethodIndex">Index of the RPC method.</param> public virtual void SendRPC(NetDataWriter stream, RPCTarget target, RPCCallers caller, int rpcMethodIndex) { if (target == RPCTarget.ClientOwner) { if (!isServer || _netIdentity.hasAuthority) { //We are not the server or we are the owner, so we can't or have no need to replicate return; } } else if (target == RPCTarget.Server) { if (isServer) { //We are the server, no need to replicate return; } } else if (target == RPCTarget.Everyone) { if (!isServer) { //We are not the server, we don't have a connection to everyone return; } } switch (target) { case RPCTarget.Server: TinyNetClient.instance.SendRPCToServer(stream, rpcMethodIndex, this); return; case RPCTarget.ClientOwner: TinyNetServer.instance.SendRPCToClientOwner(stream, rpcMethodIndex, this); return; case RPCTarget.Everyone: TinyNetServer.instance.SendRPCToAllClients(stream, rpcMethodIndex, this); return; } }
public RPCMethodInfo(string rpcName, RPCTarget nTarget, RPCCallers nCaller) { name = rpcName; target = nTarget; caller = nCaller; }
public TinyNetRPC(RPCTarget newTargets, RPCCallers newCallers) { targets = newTargets; callers = newCallers; }
public static void AddRPCMethodNameToType(string rpcName, RPCTarget nTarget, RPCCallers nCaller, Type type) { rpcMethods[type].Add(new RPCMethodInfo(rpcName, nTarget, nCaller)); }