Fix: SignalR Authorize & Firefox Compatibility
Changes in architecture to support authorization and temporary workaround for NTLM in Firefox (to be removed in SignalR 2.x). Thanks to @davidfowl
This commit is contained in:
@@ -73,8 +73,10 @@ namespace Disco.Services.Tasks
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
public delegate void UpdatedBroadcastEvent(ScheduledTaskStatusLive SessionStatus);
|
||||
public delegate void UpdatedEvent(ScheduledTaskStatus sender, string[] ChangedProperties);
|
||||
public delegate void CancelingEvent(ScheduledTaskStatus sender);
|
||||
public static event UpdatedBroadcastEvent UpdatedBroadcast;
|
||||
public event UpdatedEvent Updated;
|
||||
public event CancelingEvent Canceling;
|
||||
#endregion
|
||||
@@ -344,8 +346,8 @@ namespace Disco.Services.Tasks
|
||||
if (Updated != null)
|
||||
Updated(this, ChangedProperties);
|
||||
|
||||
if (!_isSilent)
|
||||
ScheduledTasksLiveStatusService.Broadcast(ScheduledTaskStatusLive.FromScheduledTaskStatus(this, ChangedProperties));
|
||||
if (!_isSilent && UpdatedBroadcast != null)
|
||||
UpdatedBroadcast.Invoke(ScheduledTaskStatusLive.FromScheduledTaskStatus(this, ChangedProperties));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR.Infrastructure;
|
||||
|
||||
namespace Disco.Services.Tasks
|
||||
{
|
||||
public class ScheduledTasksLiveStatusService : PersistentConnection
|
||||
{
|
||||
|
||||
protected override System.Threading.Tasks.Task OnReceived(IRequest request, string connectionId, string data)
|
||||
{
|
||||
// Add to Group
|
||||
if (!string.IsNullOrWhiteSpace(data) && data.StartsWith("/addToGroups:") && data.Length > 13)
|
||||
{
|
||||
var groups = data.Substring(13).Split(',');
|
||||
foreach (var g in groups)
|
||||
{
|
||||
this.Groups.Add(connectionId, g);
|
||||
}
|
||||
}
|
||||
return base.OnReceived(request, connectionId, data);
|
||||
}
|
||||
|
||||
internal static void Broadcast(ScheduledTaskStatusLive SessionStatus)
|
||||
{
|
||||
//var message = Models.LogLiveEvent.Create(logModule, eventType, Timestamp, Arguments);
|
||||
|
||||
var connectionManager = GlobalHost.ConnectionManager; //AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
|
||||
var connectionContext = connectionManager.GetConnectionContext<ScheduledTasksLiveStatusService>();
|
||||
connectionContext.Groups.Send(_GroupNameAll, SessionStatus);
|
||||
connectionContext.Groups.Send(SessionStatus.SessionId, SessionStatus);
|
||||
}
|
||||
|
||||
private const string _GroupNameAll = "__All";
|
||||
//private static string _QualifiedSessionName = typeof(ScheduledTasksLiveStatusService).FullName + ".";
|
||||
//private static string _QualifiedSessionNameAll = _QualifiedSessionName + "__All";
|
||||
//private static string LiveStatusGroup(string SessionId)
|
||||
//{
|
||||
// return string.Concat(_QualifiedSessionName, SessionId);
|
||||
//}
|
||||
public static string LiveStatusAll
|
||||
{
|
||||
get
|
||||
{
|
||||
//return _QualifiedTypeNameAll;
|
||||
return _GroupNameAll;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user