Example #1
0
        /// <summary>
        /// 
        /// </summary>
        public SocketListener(SocketSettings settings)
        {
            _settings = settings;
            _sessioinListen = new CacheListener("__SOCKET_SESSION_POOL", 10, OnRemoveSession);
            _resetEvent = new AutoResetEvent[1];
            _resetEvent[0] = new AutoResetEvent(false);

            _sessionPool = new SocketSessionPool();
            _readWritePool = new SocketAsyncPool(_settings.NumOfSaeaForRecSend);
            _acceptPool = new SocketAsyncPool(_settings.MaxConnection);
            int numSize = settings.NumOfSaeaForRecSend * settings.BufferSize;
            _bufferManager = new BufferManager(numSize, settings.BufferSize);
            _saeaProxy = new SocketAsyncEventArgsProxy(settings.BufferSize);
            _saeaProxy.ReceiveCompleted += OnReceiveCompleted;
            _saeaProxy.SendCompleted += OnSendCompleted;
            _saeaProxy.ClosedHandle += OnSocketClosing;
            Init();
        }
        /// <summary>
        /// 初始化配置
        /// </summary>
        public static void Intialize()
        {
            string runtimePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            _configFileName = Path.Combine(runtimePath, "Game.config.xml");
            CacheListener routeListener = new CacheListener("__GAME_CONFIG", 0, (key, value, reason) =>
            {
				if (reason == CacheRemovedReason.Changed)
                {
                    _gameConfigSetting.Init(_configFileName);
                }
            }, _configFileName);
            routeListener.Start();

            _gameConfigSetting.Init(_configFileName);
        }
Example #3
0
 private void Intialize()
 {
     try
     {
         LibPath = "";
         PythonRootPath = ConfigUtils.GetSetting("PythonRootPath", "PyScript");
         _runtimePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
         _runtimePath = Path.Combine(_runtimePath, PythonRootPath);
         _routeConfigFileName = Path.Combine(_runtimePath, "Route.config.xml");
         CacheListener routeListener = new CacheListener("__ACTION_ROUTES", 0, (key, value, reason) =>
         {
             if (reason == CacheItemRemovedReason.DependencyChanged)
             {
                 LoadRouteConfig(_routeConfigFileName);
                 //重新设置查找路径
                 PythonScriptHost.LibPath = LibPath;
                 PythonScriptHost.SetPythonSearchPath(_runtimePath);
             }
         }, _routeConfigFileName);
         routeListener.Start();
         LoadRouteConfig(_routeConfigFileName);
         bool isDebug = ConfigUtils.GetSetting("Python_IsDebug", "false").ToBool();
         PythonScriptHost.Initialize(_runtimePath, LibPath, isDebug);
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("ActionFactory load route config:{0} error{1}", _routeConfigFileName, ex);
     }
 }