/// <summary> /// Finishes caching data and then sends it over through the network. Used internally. /// </summary> /// <param name="info">Info.</param> private void Finish(SparkMessageInfo info) { if (IsEmpty) { return; } bool equal = networkVariables.OrderBy(pair => pair.Key).SequenceEqual(previousVariables.OrderBy(pair => pair.Key)); if (equal) { return; } IsWriting = false; using (RTData data = RTData.Get()) { data.SetString(1, SparkExtensions.Serialize(this)); data.SetString(2, SparkExtensions.Serialize(info)); SparkManager.instance.sparkNetwork.SendData(1, observeMethod, data); } sendCount = 0; previousVariables = networkVariables; networkVariables.Clear(); IsWriting = true; }
/// <summary> /// Sends the RPC. /// </summary> /// <param name="code">Code.</param> /// <param name="methodName">Method name.</param> /// <param name="targetPlayer">Target player.</param> /// <param name="isBuffered">If set to <c>true</c> is buffered.</param> /// <param name="isLocal">If set to <c>true</c> is local.</param> /// <param name="parameters">Parameters.</param> private void SendEvent_RPC(Guid netGuid, SparkManager.OpCode code, string methodName, int[] receiverIds, bool isBuffered, bool isLocal, params object[] parameters) { SparkRPC rpc = new SparkRPC(netGuid, methodName, receiverIds, SparkManager.instance.LocalPlayer, parameters); using (RTData data = RTData.Get()) { data.SetString(1, SparkExtensions.Serialize(rpc)); SparkManager.instance.sparkNetwork.SendData(Convert.ToInt32(code), GameSparksRT.DeliveryIntent.RELIABLE, data, receiverIds); } if (isBuffered) { if (isLocal) { LocalRPC_Buffer.Add(rpc); LocalRPC("Add_LocalRPC_Buffer", SparkTargets.Others, false, rpc); } else { RPC_Buffer.Add(rpc); LocalRPC("Add_RPC_Buffer", SparkTargets.Others, false, rpc); } } }