Esempio n. 1
0
        public async Task Update(ChangedGamespace model)
        {
            var entity = await _store.Retrieve(model.Id);

            Mapper.Map(model, entity);

            await _store.Update(entity);
        }
Esempio n. 2
0
        public async Task Enlist(string code)
        {
            var gamespace = await _gamespaceStore.FindByShareCode(code);

            if (gamespace == null)
            {
                throw new InvalidOperationException();
            }

            if (!gamespace.Players.Where(m => m.PersonId == User.Id).Any())
            {
                gamespace.Players.Add(new Data.Player
                {
                    PersonId = User.Id,
                });

                await _gamespaceStore.Update(gamespace);
            }
        }
Esempio n. 3
0
        public async Task EndExpired()
        {
            var ts = DateTimeOffset.UtcNow;

            var unended = await _gamespaceStore.List()
                          .Where(g => g.EndTime == DateTimeOffset.MinValue)
                          .ToListAsync()
            ;

            var expired = unended
                          .Where(g =>
                                 g.ExpirationTime.AddMinutes(g.CleanupGraceMinutes) < ts
                                 )
                          .ToArray()
            ;

            foreach (var gs in expired)
            {
                gs.EndTime = gs.ExpirationTime;
            }

            await _gamespaceStore.Update(expired);
        }
Esempio n. 4
0
        public async Task <ConsoleSummary> Ticket(string vmId)
        {
            var info = await _pod.Display(vmId);

            var gamespace = await _gamespaceStore.Load(info.IsolationId);

            if (gamespace != null)
            {
                gamespace.LastActivity = DateTime.UtcNow;
                await _gamespaceStore.Update(gamespace);
            }

            if (info.Url.HasValue())
            {
                var src = new Uri(info.Url);

                info.Url = info.Url.Replace(src.Host, _options.ConsoleHost) + $"?vmhost={src.Host}";
            }

            return(info);
        }