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