From 8871827c921203104051ed0cf9f0a34a80730dc9 Mon Sep 17 00:00:00 2001 From: Valens <8889280+VforValens@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:14:22 -0500 Subject: [PATCH] Update NotifierController.cs Start implementation of the NotifyAsync function from node server. Partially completed. --- .../Core/Controllers/NotifierController.cs | 52 +++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/Libraries/Core/Controllers/NotifierController.cs b/Libraries/Core/Controllers/NotifierController.cs index b10ee4e5..656fbd8e 100644 --- a/Libraries/Core/Controllers/NotifierController.cs +++ b/Libraries/Core/Controllers/NotifierController.cs @@ -1,14 +1,20 @@ using SptCommon.Annotations; using Core.Helpers; using Core.Models.Eft.Notifier; +using static System.Runtime.InteropServices.JavaScript.JSType; +using Core.Services; +using System.Diagnostics.Tracing; namespace Core.Controllers; [Injectable] public class NotifierController( HttpServerHelper _httpServerHelper, - NotifierHelper _notifierHelper -) + NotifierHelper _notifierHelper, + NotificationService _notificationService, + _timeout, + _pollInterval + ) { /// /// Resolve an array of session notifications. @@ -20,7 +26,47 @@ public class NotifierController( /// public async Task NotifyAsync(string sessionId) { - throw new NotImplementedException(); + // TODO: Finish implementation of the NotifyAsync method + // + //return new Promise((resolve) => { + // // keep track of our timeout + // let counter = 0; + + // /** + // * Check for notifications, resolve if any, otherwise poll + // * intermittently for a period of time. + // */ + // var checkNotifications = () => { + // /** + // * If there are no pending messages we should either check again later + // * or timeout now with a default response. + // */ + // if (!_notificationService.Has(sessionID)) { + // // have we exceeded timeout? if so reply with default ping message + // if (counter > _timeout) { + // return resolve([_notifierHelper.getDefaultNotification()]); + // } + + // // check again + // setTimeout(checkNotifications, _pollInterval); + + // // update our timeout counter + // counter += _pollInterval; + // return; + // } + + // /** + // * Maintaining array reference is not necessary, so we can just copy and reinitialize + // */ + // var messages = _notificationService.Get(sessionID); + + // _notificationService.UpdateMessageOnQueue(sessionID, []); + // resolve(messages); + }; + + // immediately check + checkNotifications(); + }); } ///