Пример #1
0
        public async Task <Enlistment> Enlist(Enlistee model)
        {
            string id = await _distCache.GetStringAsync(model.Code);

            if (id.IsEmpty())
            {
                throw new InvalidInvitation();
            }

            var gamespace = await _store.Load(id);

            string token = Guid.NewGuid().ToString("n");
            string name  = model.SubjectName ?? "anonymous";

            gamespace.Players.Add(new Data.Player
            {
                SubjectId   = token,
                SubjectName = name
            });

            await _store.Update(gamespace);

            return(new Enlistment
            {
                Token = token,
                GamespaceId = id
            });
        }
Пример #2
0
        public async Task <ActionResult <Enlistment> > Enlist(Enlistee model, CancellationToken ct)
        {
            var result = await _svc.Enlist(model);

            // Set an auth ticket
            string key = $"{TicketAuthentication.TicketCachePrefix}{result.Token}";

            string value = $"{result.Token}#{model.SubjectName ?? "anonymous"}";

            await _distCache.SetStringAsync(key, value, _cacheOpts, ct);

            return(Ok(result));
        }