Exemplo n.º 1
0
        /// <summary>
        /// Remove the vessels that didn't receive and update after the value specified in MsWithoutUpdatesToRemove every 5 seconds
        /// </summary>
        private IEnumerator RemoveVessels()
        {
            var seconds = new WaitForSeconds(RemoveVesselsSecInterval);

            while (true)
            {
                try
                {
                    if (!Enabled)
                    {
                        break;
                    }

                    if (PositionUpdateSystemBasicReady)
                    {
                        var vesselsToRemove = InterpolationSystem.CurrentVesselUpdate
                                              .Where(u => u.Value.InterpolationFinished && Time.time - u.Value.FinishTime > MaxSecWithoutUpdates)
                                              .Select(u => u.Key).ToArray();

                        foreach (var vesselId in vesselsToRemove)
                        {
                            InterpolationSystem.RemoveVessel(vesselId);
                            ReceivedUpdates.Remove(vesselId);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"[LMP]: Coroutine error in RemoveVessels {e}");
                }

                yield return(seconds);
            }
        }
Exemplo n.º 2
0
        private void GetUpdates()
        {
            var url = _botUrl + "/getUpdates";

            if (_currentOffset != null)
            {
                url += $"?offset={_currentOffset}";
            }

            _clientManager.SetUrl(url);
            _clientManager.RunGet((result) =>
            {
                var updates = ReceivedUpdates.FromJson(result);
                updates.result.ForEach((update =>
                {
                    _currentOffset = update.update_id + 1;
                    UpdateReceived(update);
                }));
            });
        }
Exemplo n.º 3
0
 public int GetNumberOfUpdatesInQueue()
 {
     return(ReceivedUpdates.Sum(u => u.Value.Count));
 }
Exemplo n.º 4
0
 public bool VesselHasUpdates(Guid vesselId, int minNumberOfUpdates)
 {
     return(ReceivedUpdates.ContainsKey(vesselId) && ReceivedUpdates[vesselId].Count >= minNumberOfUpdates);
 }
Exemplo n.º 5
0
 public override void OnDisabled()
 {
     base.OnDisabled();
     InterpolationSystem.ResetSystem();
     ReceivedUpdates.Clear();
 }