Example #1
0
 public WebRpcHandler(string baseUrl,
     Dictionary<string, object> environment,
     IRpcHandlerAppCounters rpcAppCounters = null,
     HttpRequestQueueOptions httpRequestQueueOptions = null)
     : this(baseUrl, environment, new HttpRequestQueue(), rpcAppCounters, httpRequestQueueOptions)
 {
 }
Example #2
0
        public HiveHostGame(
            string gameName,
            RoomCacheBase roomCache,
            IGameStateFactory gameStateFactory = null,
            int maxEmptyRoomTTL = 0,
            IPluginManager pluginManager = null,
            string pluginName = "",
            Dictionary<string, object> environment = null,
            int lastTouchLimitMilliseconds = 0,
            int lastTouchCheckIntervalMilliseconds = 0,
            HttpRequestQueueOptions httpRequestQueueOptions = null,
            ExtendedPoolFiber executionFiber = null
            )
            : base(gameName, roomCache, gameStateFactory, maxEmptyRoomTTL, lastTouchLimitMilliseconds, lastTouchCheckIntervalMilliseconds, executionFiber)
        {
            this.pluginManager = pluginManager;

            if (httpRequestQueueOptions == null)
            {
                httpRequestQueueOptions = new HttpRequestQueueOptions();
            }

            this.httpRequestQueue.MaxErrorRequests = httpRequestQueueOptions.HttpQueueMaxTimeouts;
            this.httpRequestQueue.MaxTimedOutRequests = httpRequestQueueOptions.HttpQueueMaxErrors;
            this.httpRequestQueue.ReconnectInterval = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueReconnectInterval);
            this.httpRequestQueue.QueueTimeout = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueQueueTimeout);
            this.httpRequestQueue.MaxQueuedRequests = httpRequestQueueOptions.HttpQueueMaxQueuedRequests;
            this.httpRequestQueue.MaxBackoffInMilliseconds = httpRequestQueueOptions.HttpQueueMaxBackoffTime;
            this.httpRequestQueue.MaxConcurrentRequests = httpRequestQueueOptions.HttpQueueMaxConcurrentRequests;

            this.httpQueueRequestTimeout = httpRequestQueueOptions.HttpQueueRequestTimeout;

            this.httpRequestQueue.SetCounters(this);

            this.Environment = environment ?? new Dictionary<string, object>
                                       {
                                           {"AppId", GetHwId()},
                                           {"AppVersion", ""},
                                           {"Region", ""},
                                           {"Cloud", ""},
                                       };
            this.InitPlugin(pluginName);
            if (this.Plugin == null)
            {
                throw new Exception(string.Format("Failed to craete plugin '{0}'", pluginName));
            }

            var errorPlugin = this.Plugin as ErrorPlugin;
            if (errorPlugin != null)
            {
                Log.ErrorFormat("Game {0} is created with ErrorPlugin. message:{1}", this.Name, errorPlugin.Message);
            }

            this.customTypeCache.TypeMapper = this;
            this.callEnv = new CallEnv(this.Plugin, this.Name);
        }
Example #3
0
        public WebRpcHandler(string baseUrl,
            Dictionary<string, object> environment, HttpRequestQueue queue,
            IRpcHandlerAppCounters rpcAppCounters = null, 
            HttpRequestQueueOptions httpRequestQueueOptions = null)
        {
            this.rpcAppCounters = rpcAppCounters ?? nullAppCounters;
            this.baseUrl = baseUrl;
            this.environment = environment;

            if (httpRequestQueueOptions == null)
            {
                httpRequestQueueOptions = new HttpRequestQueueOptions();
            }

            this.httpRequestQueue = queue;
            this.httpRequestQueue.SetCounters(this);

            this.httpRequestQueue.MaxErrorRequests = httpRequestQueueOptions.HttpQueueMaxTimeouts;
            this.httpRequestQueue.MaxTimedOutRequests = httpRequestQueueOptions.HttpQueueMaxErrors;
            this.httpRequestQueue.ReconnectInterval = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueReconnectInterval);
            this.httpRequestQueue.QueueTimeout = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueQueueTimeout);
            this.httpRequestQueue.MaxQueuedRequests = httpRequestQueueOptions.HttpQueueMaxQueuedRequests;
            this.httpRequestQueue.MaxBackoffInMilliseconds = httpRequestQueueOptions.HttpQueueMaxBackoffTime;
            this.httpRequestQueue.MaxConcurrentRequests = httpRequestQueueOptions.HttpQueueMaxConcurrentRequests;

            this.httpRequestTimeout = httpRequestQueueOptions.HttpQueueRequestTimeout;
        }