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:
@@ -237,13 +237,6 @@ namespace Disco.Services.Logging
|
||||
|
||||
var reInitalizeJobDetail = new JobDetailImpl("DiscoLogContextReinialize", typeof(LogReInitalizeJob));
|
||||
|
||||
// Simple Trigger - Issue with Day light savings
|
||||
//var reInitalizeTrigger = TriggerBuilder.Create()
|
||||
// .WithIdentity("DiscoLogContextReinializeTrigger")
|
||||
// .StartAt(DateBuilder.TomorrowAt(0,0,0))
|
||||
// .WithSchedule(SimpleScheduleBuilder.Create().WithIntervalInHours(24).RepeatForever())
|
||||
// .Build();
|
||||
// Use Cron Schedule instead
|
||||
var reInitalizeTrigger = TriggerBuilder.Create()
|
||||
.WithIdentity("DiscoLogContextReinializeTrigger")
|
||||
.StartNow()
|
||||
@@ -252,13 +245,6 @@ namespace Disco.Services.Logging
|
||||
|
||||
_ReInitializeScheduler.ScheduleJob(reInitalizeJobDetail, reInitalizeTrigger);
|
||||
}
|
||||
public static string LiveLogAllEventsGroupName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Targets.LogLiveContext.LiveLogNameAll;
|
||||
}
|
||||
}
|
||||
|
||||
private LogContext(string PersistantStorePath, string PersistantStoreConnectionString)
|
||||
{
|
||||
@@ -286,7 +272,7 @@ namespace Disco.Services.Logging
|
||||
{
|
||||
string args = null;
|
||||
if (Args != null && Args.Length > 0)
|
||||
{ //args = fastJSON.JSON.Instance.ToJSON(Args, false); // Old fastJSON Implementation
|
||||
{
|
||||
args = JsonConvert.SerializeObject(Args);
|
||||
}
|
||||
using (var context = new Targets.LogPersistContext(PersistantStoreConnectionString))
|
||||
|
||||
@@ -1,55 +1,21 @@
|
||||
using System;
|
||||
using Disco.Services.Logging.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR.Infrastructure;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Services.Logging.Targets
|
||||
{
|
||||
public class LogLiveContext : PersistentConnection
|
||||
public static class LogLiveContext
|
||||
{
|
||||
public delegate void LogBroadcastEvent(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments);
|
||||
public static event LogBroadcastEvent LogBroadcast;
|
||||
|
||||
protected override System.Threading.Tasks.Task OnReceived(IRequest request, string connectionId, string data)
|
||||
internal static void Broadcast(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments)
|
||||
{
|
||||
// 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);
|
||||
if (LogBroadcast != null)
|
||||
LogBroadcast.Invoke(logModule, eventType, Timestamp, Arguments);
|
||||
}
|
||||
|
||||
internal static void Broadcast(LogBase logModule, Models.LogEventType eventType, DateTime Timestamp, params object[] Arguments)
|
||||
{
|
||||
var message = Models.LogLiveEvent.Create(logModule, eventType, Timestamp, Arguments);
|
||||
|
||||
var connectionManager = GlobalHost.ConnectionManager;
|
||||
var connectionContext = connectionManager.GetConnectionContext<LogLiveContext>();
|
||||
connectionContext.Groups.Send(_GroupNameAll, message);
|
||||
connectionContext.Groups.Send(logModule.ModuleName, message);
|
||||
}
|
||||
|
||||
private const string _GroupNameAll = "__All";
|
||||
//private static string _QualifiedTypeName = typeof(LogLiveContext).FullName + ".";
|
||||
//private static string _QualifiedTypeNameAll = _QualifiedTypeName + "__All";
|
||||
//private static string LiveLogNameGroup(string LogName)
|
||||
//{
|
||||
// return string.Concat(_QualifiedTypeName, LogName);
|
||||
//}
|
||||
public static string LiveLogNameAll
|
||||
{
|
||||
get
|
||||
{
|
||||
//return _QualifiedTypeNameAll;
|
||||
return _GroupNameAll;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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