コード例 #1
0
        /// <inheritdoc />
        public Task InitializeAsync(CancellationToken cancellationToken = default)
        {
            var logger = _loggerFactory.CreateLogger(typeof(FireAndForget));

            FireAndForget.SetLogger(logger);

            return(Task.CompletedTask);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: kochol/ardb-sharp
 public void FireAndForgetTest()
 {
     FireAndForget.MainConnection = _connection;
     for (int i = 0; i < 200; i++)
     {
         FireAndForget.StringAppend("0", "str", i);
         FireAndForget.ListRightPush("0", "temp", i);
     }
     Thread.Sleep(1000);
 }
コード例 #3
0
        public async Task AllFiredActionsShouldBeExecuted(int count)
        {
            var stack = new ConcurrentStack <int>();

            for (var i = 0; i < count; ++i)
            {
                var localIndex = i;
                FireAndForget.Run(() => stack.Push(localIndex));
            }
            await Task.Delay(30 *count);

            stack.Count.ShouldBe(count);
        }
コード例 #4
0
        public async Task DeleteLobbyAsync(long lobby_id)
        {
            var lobby = await GetLobbyById(lobby_id);

            if (lobby == null)
            {
                return;
            }

            foreach (var t in lobby.Teams)
            {
                foreach (var p in t)
                {
                    FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:p:" + p);
                }
            }

            FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:" + lobby_id);
        }
コード例 #5
0
        /// <summary>
        /// Get player lobby id
        /// </summary>
        /// <param name="player_id"> player id</param>
        /// <returns>returns 0 if not found otherwise returns lobby id</returns>
        public async ValueTask <Lobby> GetPlayerLobby(long player_id)
        {
            long lobby_id = 0;

            using (var db = await DataContext.Db.GetDatabaseAsync(DatabaseName.Lobbies))
                lobby_id = Database.ToLong(await db.Value.StringGetAsync("l:p:" + player_id));

            if (lobby_id == 0)
            {
                return(null);
            }

            var lobby = await GetLobbyById(lobby_id);

            if (lobby == null)
            {
                // delete player from deleted lobby
                FireAndForget.KeyDelete(DatabaseName.Lobbies, "l:p:" + player_id);
            }

            return(lobby);
        }
コード例 #6
0
 public void SetException(Exception exception) => FireAndForget.OnException(exception);
コード例 #7
0
 /// <summary>
 /// Update player in fire and forget mode
 /// </summary>
 /// <param name="player">Player to update</param>
 public void UpdatePlayerFAF(Player player)
 {
     FireAndForget.StringSet(DatabaseName.Players, "p:" + player.Id, MessagePackSerializer.Serialize(player));
 }