public static async Task TestServiceAsync()
        {
            ToDoTask t1 = new ToDoTask
            {
                UserName        = "******",
                TaskDescription = "1",
                DueDate         = DateTime.UtcNow.AddMinutes(2)
            };
            ToDoTask t2 = new ToDoTask
            {
                UserName        = "******",
                TaskDescription = "2",
                DueDate         = DateTime.UtcNow.AddMinutes(2)
            };
            ToDoTask t3 = new ToDoTask
            {
                UserName        = "******",
                TaskDescription = "3",
                DueDate         = DateTime.UtcNow.AddMinutes(2)
            };

            await CacheS.AddAsync(t1);

            await CacheS.AddAsync(t2);

            await CacheS.AddAsync(t3);


            //var cache = await CacheS.GetAsync("1");



            await QueueS.SendAsync(t1);

            await QueueS.SendAsync(t2);

            await QueueS.SendAsync(t3);



            var service = new TaskToDoService(QueueS, CacheS);



            //var res = await service.GetAsync("1");
        }
Exemple #2
0
        public async Task JoinGame(ChannelEvent evnt)
        {
            string name    = evnt.Data.name;
            string groupId = evnt.Data.id;
            await Groups.AddToGroupAsync(Context.ConnectionId, (string)evnt.Data.id);

            var model = new PlayerModel()
            {
                ConnectionId = Context.ConnectionId,
                GroupId      = evnt.Data.id,
                name         = evnt.Data.name
            };

            evnt.Data = await GameCache.GetValueAsync <GameModel>(groupId);

            ((GameModel)evnt.Data).playerList.Add(model);

            await GameCache.AddAsync(model.GroupId, evnt.Data);

            evnt.ChannelName = "UpdateGame";
            await Clients.Group(groupId).SendAsync("OnEvent", evnt);
        }