/// <summary> /// does not check seen for isValid /// </summary> /// <param name="seen"></param> /// <param name="forced">for receiving LastSeen for self</param> public void receive(LastSeen seen, bool forced = false) { if (seen.Entity == CubeBlock.CubeGrid && !forced) { //{ // alwaysLog("do not tell me about myself: ", "receive()", Logger.severity.TRACE); return; } //} LastSeen toUpdate; if (myLastSeen.TryGetValue(seen.Entity.EntityId, out toUpdate)) { if (seen.update(ref toUpdate)) { //if (toUpdate.Entity.getBestName().looseContains("Leo"))// toUpdate.LastSeenAt.secondsSince() > 3) // log("updating: " + seen.Entity.getBestName(), "receive()", Logger.severity.TRACE); myLastSeen.Remove(toUpdate.Entity.EntityId); myLastSeen.Add(toUpdate.Entity.EntityId, toUpdate); } //else // if (toUpdate.Entity.getBestName().looseContains("Leo")) // log("not updating: " + seen.Entity.getBestName(), "receive()", Logger.severity.TRACE); } else { //{ myLastSeen.Add(seen.Entity.EntityId, seen); } // log("got a new last seen: " + seen.Entity.DisplayName, "receive()", Logger.severity.TRACE); //} }
/// <summary> /// <para>Internal receive method. Adds the LastSeen to this storage or updates an existing one.</para> /// <para>lock_m_lastSeen should be exclusively locked before invoking this method.</para> /// </summary> private void in_Receive(LastSeen seen) { LastSeen toUpdate; if (m_lastSeen.TryGetValue(seen.Entity.EntityId, out toUpdate)) { if (seen.update(ref toUpdate)) { m_lastSeen[toUpdate.Entity.EntityId] = toUpdate; } } else { m_lastSeen.Add(seen.Entity.EntityId, seen); } }
/// <summary> /// does not check seen for isValid /// </summary> /// <param name="forced">for receiving LastSeen for self</param> public void Receive(LastSeen seen, bool forced = false) { if (seen.Entity == Entity.Invoke() && !forced) return; LastSeen toUpdate; using (lock_m_lastSeen.AcquireExclusiveUsing()) if (m_lastSeen.TryGetValue(seen.Entity.EntityId, out toUpdate)) { if (seen.update(ref toUpdate)) m_lastSeen[toUpdate.Entity.EntityId] = toUpdate; } else m_lastSeen.Add(seen.Entity.EntityId, seen); }
/// <summary> /// <para>Internal receive method. Adds the LastSeen to this storage or updates an existing one.</para> /// <para>lock_m_lastSeen should be exclusively locked before invoking this method.</para> /// </summary> private void in_Receive(LastSeen seen) { LastSeen toUpdate; if (m_lastSeen.TryGetValue(seen.Entity.EntityId, out toUpdate)) { if (seen.update(ref toUpdate)) m_lastSeen[toUpdate.Entity.EntityId] = toUpdate; } else m_lastSeen.Add(seen.Entity.EntityId, seen); }