public void Rpc(byte rpcId, RpcMode mode, params object[] args) { var size = 0; foreach (var arg in args) { if (arg == null) { throw new NullReferenceException("Cannot serialize null value"); } size += _room.Serializer.SizeOf(arg); } var msg = StartMessage(rpcId, mode.ReliabilityMode(), size, mode.BroadcastMode()); foreach (var arg in args) { _room.Serializer.Serialize(arg, msg); } SendMessage(msg, mode.ReliabilityMode()); }
internal void SendMessage(NetMessage msg, RpcMode mode) { var reliable = mode.ReliabilityMode(); var broadcast = mode.BroadcastMode(); if (!Owner.IsValid) { if (broadcast == BroadcastMode.Others) { broadcast = BroadcastMode.All; } else if (broadcast == BroadcastMode.Owner) { NetMessage.RecycleMessage(msg); return; } } ImplSendMessage(msg, reliable, broadcast); }