Radarr/NzbDrone.Web/Controllers/NotificationController.cs

48 lines
1.2 KiB
C#
Raw Normal View History

2012-01-23 07:43:54 +00:00
using System.Threading;
using System.Web.Mvc;
2012-01-23 07:43:54 +00:00
using System.Web.UI;
using NzbDrone.Core.Providers;
2012-07-27 21:31:33 +00:00
using StackExchange.Profiling;
namespace NzbDrone.Web.Controllers
{
public class NotificationController : Controller
{
2011-11-21 04:43:16 +00:00
private readonly NotificationProvider _notificationProvider;
//
// GET: /Notification/
2011-04-08 23:48:47 +00:00
public NotificationController(NotificationProvider notificationProvider)
{
2011-11-21 04:43:16 +00:00
_notificationProvider = notificationProvider;
}
[HttpGet]
2012-01-23 07:43:54 +00:00
[OutputCache(NoStore = true, Location = OutputCacheLocation.None)]
public JsonResult Comet(string message)
{
MiniProfiler.Stop(true);
var currentMessage = GetCurrentMessage();
2011-07-02 17:41:10 +00:00
while (message == currentMessage)
{
Thread.Sleep(250);
currentMessage = GetCurrentMessage();
}
return Json(currentMessage, JsonRequestBehavior.AllowGet);
}
private string GetCurrentMessage()
{
2011-11-21 04:43:16 +00:00
var notification = _notificationProvider.GetCurrent();
2011-11-21 04:43:16 +00:00
if (notification != null)
return notification.CurrentMessage;
return string.Empty;
}
}
2011-04-10 02:44:01 +00:00
}