public async Task ExposureStateUpdatedAsync(IEnumerable <ExposureWindow> windows,
                                                    IEnumerable <DailySummary>?summaries)
        {
            Debug.WriteLine("ExposureStateUpdatedAsync is called");

            List <DateTime> validDates = ExposureDetectedHelper.DeleteDatesOfExposureOlderThan14DaysAndReturnNewList();

            bool            shouldSendMessage             = false;
            List <DateTime> datesOfExposuresOverThreshold = new List <DateTime>();

            foreach (DailySummary dailySummary in summaries)
            {
                if (ExposureDetectedHelper.RiskInDailySummaryAboveThreshold(dailySummary) &&
                    ExposureDetectedHelper.HasNotShownExposureNotificationForDate(dailySummary.Timestamp.Date,
                                                                                  validDates))
                {
                    datesOfExposuresOverThreshold.Add(dailySummary.Timestamp.Date);
                    shouldSendMessage = true;
                }
            }

            if (shouldSendMessage)
            {
                await MessageUtils.CreateMessage(this);

                await ExposureDetectedHelper.UpdateDatesOfExposures(datesOfExposuresOverThreshold);
            }

            ServiceLocator.Current.GetInstance <IDeveloperToolsService>().SaveExposureWindows(windows);
            ServiceLocator.Current.GetInstance <IDeveloperToolsService>().SaveLastDailySummaries(summaries);
        }
コード例 #2
0
        /// <summary>
        /// Send a string to players or a player in the lobby
        /// </summary>
        /// <param name="objectToSend">string message to send. Can be JSON</param>
        /// <param name="peerId">The id of the peer you want the message to go to. Leave null if you want to send to all players</param>
        /// <param name="code">Coop code used to distinguish this message from others. Like a lock and key for reading messages</param>
        public static void SendMessage(this NKMultiGameInterface nkGI, Il2CppSystem.String objectToSend, byte?peerId = null, string code = "")
        {
            Message message = MessageUtils.CreateMessage(objectToSend, code);

            if (peerId.HasValue && peerId != null)
            {
                nkGI.SendToPeer(peerId.Value, message);
            }
            else
            {
                nkGI.relayConnection.Writer.Write(message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Send a string to players or a player in the lobby
        /// </summary>
        /// <param name="objectToSend">string message to send. Can be JSON</param>
        /// <param name="peerId">The id of the peer you want the message to go to. Leave null if you want to send to all players</param>
        /// <param name="code">Coop code used to distinguish this message from others. Like a lock and key for reading messages</param>
        public static void SendMessage(this NKMultiGameInterface nkGI, Il2CppSystem.String objectToSend, byte?peerId = null, string code = "")
        {
            Message message = MessageUtils.CreateMessage(objectToSend, code);

            var str = Il2CppSystem.Text.Encoding.Default.GetString(message.bytes);

            MelonLoader.MelonLogger.Msg($"str: {str}");

            if (peerId.HasValue && peerId != null)
            {
                nkGI.SendToPeer(peerId.Value, message);
            }
            else
            {
                nkGI.relayConnection.Writer.Write(message);
            }
        }
コード例 #4
0
        public static async Task EvaluateRiskInSummaryAndCreateMessage(ExposureDetectionSummary summary, object messageSender)
        {
            if (summary.MatchedKeyCount == 0)
            {
                Debug.WriteLine($"{_logPrefix}: MatchedKeyCount was 0, so no message was shown");
                return;
            }

            if (summary.HighestRiskScore < 1)
            {
                Debug.WriteLine($"{_logPrefix}: Highest risk score is less than 1");
                return;
            }

            if (!IsAttenuationDurationOverThreshold(summary))
            {
                Debug.WriteLine($"{_logPrefix}: No exposure incidents were above the exposure time threshold");
                return;
            }

            await MessageUtils.CreateMessage(messageSender);
        }
コード例 #5
0
        public async Task SimulateExposureMessage(int notificationTriggerInSeconds = 0)
        {
            await Task.Delay(notificationTriggerInSeconds * 1000);

            await MessageUtils.CreateMessage(this, _messageDateTime);
        }