Files
Disco/Disco.Services/Jobs/Noticeboards/NoticeboardUpdatesHub.cs
T
2014-08-26 16:27:37 +10:00

46 lines
1.4 KiB
C#

using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System;
using System.Threading.Tasks;
namespace Disco.Services.Jobs.Noticeboards
{
[HubName("noticeboardUpdates")] // Public
public class NoticeboardUpdatesHub : Hub
{
public static IHubContext HubContext { get; private set; }
static NoticeboardUpdatesHub()
{
HubContext = GlobalHost.ConnectionManager.GetHubContext<NoticeboardUpdatesHub>();
}
public override Task OnConnected()
{
var noticeboardId = Context.QueryString["Noticeboard"];
if (string.IsNullOrWhiteSpace(noticeboardId))
throw new ArgumentNullException("Noticeboard");
switch (noticeboardId)
{
case HeldDevicesForUsers.Name:
Groups.Add(Context.ConnectionId, HeldDevicesForUsers.Name);
break;
case HeldDevices.Name:
Groups.Add(Context.ConnectionId, HeldDevices.Name);
break;
default:
throw new ArgumentException("Invalid Noticeboard Specified", "Noticeboard");
}
return base.OnConnected();
}
public static void SetTheme(string ThemeName)
{
HubContext.Clients.All.setTheme(ThemeName);
}
}
}