public void EchoChangeRequest(ushort transactionID, ushort objectID, ulong destinationPlayer) { if (!GetAuthorized()) { Debug.LogError("Not authorized to echo"); return; } StateChangeEcho echo = new StateChangeEcho(transactionID, objectID); MeshPacket packet = new MeshPacket(); packet.SetPacketType(PacketType.DatabaseChangeEcho); packet.SetContents(echo.GetSerializedBytes()); packet.SetTargetPlayerId(destinationPlayer); packet.SetSourceObjectId((ushort)ReservedObjectIDs.DatabaseObject); packet.SetSourcePlayerId(GetIdentity().GetOwnerID()); packet.SetTargetObjectId((ushort)ReservedObjectIDs.DatabaseObject); packet.SetSubcomponentID(GetSubcomponentID()); GetIdentity().RoutePacket(packet); }
public void ReceivePacket(MeshPacket p) { if (p.GetPacketType() == PacketType.DatabaseChangeEcho) { if (p.GetSourcePlayerId() != netDB.GetIdentity().GetOwnerID()) { Debug.LogError("User that does not own the database is trying to give us echoes"); return; } StateChangeEcho echo; echo = StateChangeEcho.ParseSerializedBytes(p.GetContents()); if (callbackRegistry.ContainsKey(echo.GetTransactionID()) == false) { Debug.LogError("Echoed transaction ID is not present in transaction registry"); return; } callbackRegistry[echo.GetTransactionID()].id = echo.GetObjectID(); //fulfill reference population, should trigger the waiting coroutine callbackRegistry.Remove(echo.GetTransactionID()); callbackTimers.Remove(echo.GetTransactionID()); } }