예제 #1
0
 public void SetConfiguration(dynamic metadata)
 {
     if (metadata.gameSession != null)
     {
         _config = ((JObject)metadata.gameSession).ToObject <GameSessionConfiguration>();
     }
 }
예제 #2
0
        public async Task <Server> GetServer(string gameSessionId, GameSessionConfiguration config)
        {
            var candidate = _subPools.Reverse <IServerPool>().FirstOrDefault(p => p.ServersReady > 0);

            if (candidate != null)
            {
                return(await candidate.GetServer(gameSessionId, config));
            }

            candidate = _subPools.FirstOrDefault(p => p.CanAcceptRequest);
            return(await candidate.GetServer(gameSessionId, config));
        }
예제 #3
0
        public Task <Server> GetServer(string gameSessionId, GameSessionConfiguration config)
        {
            if (!isRunning)
            {
                throw new InvalidOperationException("Pool not running");
            }
            var tcs = new TaskCompletionSource <Server>();

            _pendingRequests.Enqueue(new GameServerRequest {
                RequestCompletedCompletionSource = tcs, Id = gameSessionId, GameSessionConfiguration = config
            });

            return(tcs.Task);
        }
 public GameSessionContext(ISceneHost scene, GameSessionConfiguration config, IGameSessionService service)
 {
     Scene   = scene;
     Config  = config;
     Service = service;
 }
예제 #5
0
 public Task Create(string template, string id, GameSessionConfiguration config)
 {
     return(management.CreateScene(id, template, false, false, JObject.FromObject(new { gameSession = config })));
 }