Exemplo n.º 1
0
        private void Initialize()
        {
            _server = _fluentSocketFactory.CreateServer(_option.Setting);

            var sessionService = _serviceProvider.CreateInstance <CustomSessionService>(new Action <ISocketSession>(session =>
            {
                _socketSession     = session;
                _isClientConnected = true;
            }));

            _server.RegisterSessionService(sessionService);

            var performanceServiceSetting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.LogInformation("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, _performanceKey, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, performanceServiceSetting);
        }