public async Task <bool> RemovePlayer(long id, Guid sessionId) { try { if (!ContainsKey(id)) { return(true); } var player = this[id]; player.Timer.Stop(); if (Redis.IsConnected) { await Redis.CachePlayer(player); } await PlayerDb.Save(player); return(player.Device.SessionId == sessionId && TryRemove(id, out var _)); } catch (Exception exception) { Logger.Log(exception, Enums.LogType.Error); return(false); } }
public async Task <bool> RemovePlayer(long id, Guid sessionId, bool force = false) { try { if (!ContainsKey(id)) { return(true); } var player = this[id]; await PlayerDb.Save(player); if (force) { return(TryRemove(id, out var _)); } return(player.Device.SessionId == sessionId && TryRemove(id, out var _)); } catch (Exception exception) { Logger.Log(exception, Enums.LogType.Error); return(false); } }