Fix nullref exception and added logging

This commit is contained in:
Bond_009
2019-12-26 20:57:46 +01:00
parent 976459d3e8
commit 5ca68f9623
6 changed files with 41 additions and 65 deletions

View File

@@ -1726,6 +1726,7 @@ namespace Emby.Server.Implementations.Session
string.Equals(i.Client, client));
}
/// <inheritdoc />
public SessionInfo GetSessionByAuthenticationToken(AuthenticationInfo info, string deviceId, string remoteEndpoint, string appVersion)
{
if (info == null)
@@ -1733,7 +1734,7 @@ namespace Emby.Server.Implementations.Session
throw new ArgumentNullException(nameof(info));
}
var user = info.UserId.Equals(Guid.Empty)
var user = info.UserId == Guid.Empty
? null
: _userManager.GetUserById(info.UserId);

View File

@@ -56,7 +56,7 @@ namespace Emby.Server.Implementations.Session
}
else
{
_logger.LogWarning("Unable to determine session based on url: {0}", e.Argument.Url);
_logger.LogWarning("Unable to determine session based on query string: {0}", e.Argument.QueryString);
}
}

View File

@@ -53,11 +53,12 @@ namespace Emby.Server.Implementations.Session
private void OnConnectionClosed(object sender, EventArgs e)
{
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
var connection = (IWebSocketConnection)sender;
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
_sockets.Remove(connection);
_sessionManager.CloseIfNeeded(_session);
connection.Closed -= OnConnectionClosed;
connection.Dispose();
_sessionManager.CloseIfNeeded(_session);
}
/// <inheritdoc />