Fixes SignalR bug ... but without any explanation
This commit is contained in:
@ -38,6 +38,7 @@ namespace Yavsc
|
||||
if (Context.User != null)
|
||||
{
|
||||
isAuth = Context.User.Identity.IsAuthenticated;
|
||||
userName = Context.User.Identity.Name;
|
||||
var group = isAuth ?
|
||||
"authenticated" : "anonymous";
|
||||
// Log ("Cx: " + group);
|
||||
@ -54,8 +55,9 @@ namespace Yavsc
|
||||
UserAgent = Context.Request.Headers["User-Agent"],
|
||||
Connected = true
|
||||
});
|
||||
db.SaveChanges(user.Id);
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else Groups.Add(Context.ConnectionId, "anonymous");
|
||||
@ -76,16 +78,16 @@ namespace Yavsc
|
||||
var cx = db.Connections.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
|
||||
if (cx != null)
|
||||
{
|
||||
var user = db.Users.Single(u => u.UserName == userName);
|
||||
if (stopCalled)
|
||||
{
|
||||
var user = db.Users.Single(u => u.UserName == userName);
|
||||
user.Connections.Remove(cx);
|
||||
}
|
||||
else
|
||||
{
|
||||
cx.Connected = false;
|
||||
}
|
||||
db.SaveChanges(user.Id);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,7 +110,7 @@ namespace Yavsc
|
||||
if (cx != null)
|
||||
{
|
||||
cx.Connected = true;
|
||||
db.SaveChanges(user.Id);
|
||||
db.SaveChanges();
|
||||
}
|
||||
else cx = new Connection { ConnectionId = Context.ConnectionId,
|
||||
UserAgent = Context.Request.Headers["User-Agent"],
|
||||
@ -145,9 +147,10 @@ namespace Yavsc
|
||||
var cx = db.Connections.SingleOrDefault(c=>c.ConnectionId == Context.ConnectionId);
|
||||
if (cx!=null) {
|
||||
db.Connections.Remove(cx);
|
||||
db.SaveChanges(cx.ApplicationUserId);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ using Microsoft.AspNet.Localization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.AspNet.Http.Extensions;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -23,7 +24,6 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Yavsc.Extensions;
|
||||
using Yavsc.Formatters;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
@ -232,7 +232,6 @@ namespace Yavsc
|
||||
IOptions<RequestLocalizationOptions> localizationOptions,
|
||||
IOptions<OAuth2AppSettings> oauth2SettingsContainer,
|
||||
RoleManager<IdentityRole> roleManager,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IAuthorizationService authorizationService,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
@ -321,7 +320,7 @@ namespace Yavsc
|
||||
{
|
||||
foreach (var c in db.Connections)
|
||||
db.Connections.Remove(c);
|
||||
db.SaveChanges("Startup");
|
||||
db.SaveChanges();
|
||||
}
|
||||
});
|
||||
|
||||
@ -336,14 +335,11 @@ namespace Yavsc
|
||||
|
||||
ConfigureOAuthApp(app, SiteSetup);
|
||||
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
||||
app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"),
|
||||
branch =>
|
||||
{
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
});
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
ConfigureWorkflow(app, SiteSetup);
|
||||
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"fr"));
|
||||
app.UseSession();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
|
Reference in New Issue
Block a user