Example #1
0
        public async Task FeedToClients(List <SniperInfo> snipeList, ChannelInfo channelInfo)
        {
            // Remove any clients that have disconnected
            if (GlobalSettings.ThreadPause)
            {
                return;
            }
            _arrSocket.RemoveAll(x => !IsConnected(x.Client));
            var verifiedSniperInfos    = SkipLaggedPokemonLocationValidator.FilterNonAvailableAndUpdateMissingPokemonId(snipeList);
            var verifiedUnsentMessages = _messageCache.FindUnSentMessages(verifiedSniperInfos);
            var sortedMessages         = verifiedUnsentMessages.OrderBy(m => m.ExpirationTimestamp).ToList();

            foreach (var target in sortedMessages)
            {
                if (!GlobalSettings.PokekomsToFeedFilter.Contains(target.Id.ToString()) && GlobalSettings.UseFilter)
                {
                    Log.Info($"Ignoring {target.Id}, it's not in Filterlist");
                    continue;
                }

                foreach (var socket in _arrSocket) // Repeat for each connected client (socket held in a dynamic array)
                {
                    try
                    {
                        var networkStream = socket.GetStream();
                        var s             = new StreamWriter(networkStream);

                        s.WriteLine(JsonConvert.SerializeObject(target));
                        s.Flush();
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Caught exception", e);
                    }
                }
                // debug output
                if (GlobalSettings.Output != null)
                {
                    GlobalSettings.Output.PrintPokemon(target, channelInfo);
                }

                const string timeFormat = "HH:mm:ss";
                Log.Pokemon($"{channelInfo}: {target.Id} at {target.Latitude.ToString(CultureInfo.InvariantCulture)},{target.Longitude.ToString(CultureInfo.InvariantCulture)}"
                            + " with " + (!target.IV.Equals(default(double)) ? $"{target.IV}% IV" : "unknown IV")
                            +
                            (target.ExpirationTimestamp != default(DateTime)
                                ? $" until {target.ExpirationTimestamp.ToString(timeFormat)}"
                                : ""));
            }
        }
 public void VerifySkipLaggedIsWorkingTest()
 {
     Assert.IsTrue(SkipLaggedPokemonLocationValidator.VerifySkipLaggedIsWorking());
 }