Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }