Exemplo n.º 1
0
        public async STT.Task JoinScenario(Guid scenarioId)
        {
            if ((await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded)
            {
                await Groups.AddToGroupAsync(Context.ConnectionId, $"{EngineGroups.GetSystemGroup(scenarioId)}");
            }
            else
            {
                var scenario = await _db.Scenarios
                               .Include(x => x.Users)
                               .Where(x => x.Id == scenarioId)
                               .SingleOrDefaultAsync();

                if (scenario.Users.Any(x => x.UserId == _user.GetId()))
                {
                    await Groups.AddToGroupAsync(Context.ConnectionId, $"{scenario.Id}");
                }
            }
        }
Exemplo n.º 2
0
        public async STT.Task LeaveScenario(Guid scenarioId)
        {
            await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"{EngineGroups.GetSystemGroup(scenarioId)}");

            await Groups.RemoveFromGroupAsync(Context.ConnectionId, scenarioId.ToString());
        }