<commit_before>using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using SuperSocket;
using SuperSocket.Server;
using SuperSocket.WebSocket.Server;
using SuperSocket.SessionContainer;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;


namespace WebSocketPushServer
{
    class ServerPushMiddleware : MiddlewareBase
    {
        private ISessionContainer _sessionContainer;

        private ILogger<ServerPushMiddleware> _logger;

        public ServerPushMiddleware(IServiceProvider serviceProvider, ILogger<ServerPushMiddleware> logger)
        {
            _sessionContainer = serviceProvider.GetSessionContainer();
            _logger = logger;
        }

        private Timer _timer;

        private int _interval = 60;

        private int _total;

        public override void Start(IServer server)
        {
            _timer = new Timer(OnTimerCallback, null, 1000 * _interval, 1000 * _interval);
        }

        private void OnTimerCallback(object state)
        {
            _timer.Change(Timeout.Infinite, Timeout.Infinite);

            try
            {
                Push().GetAwaiter().GetResult();
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception happened in Push().");
            }

            _timer.Change(1000 * _interval, 1000 * _interval);
        }

        private async ValueTask Push()
        {<commit_msg>improved the server push sample<commit_after>using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using SuperSocket;
using SuperSocket.Server;
using SuperSocket.WebSocket.Server;
using SuperSocket.SessionContainer;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;


namespace WebSocketPushServer
{
    class ServerPushMiddleware : MiddlewareBase
    {
        private ISessionContainer _sessionContainer;

        private IServiceProvider _serviceProvider;

        private static ILogger _logger;

        public ServerPushMiddleware(IServiceProvider serviceProvider, ILogger<ServerPushMiddleware> logger)
        {
            _serviceProvider = serviceProvider;
            _logger = logger;
        }

        private Timer _timer;

        private int _interval = 1;

        private int _total;

        public override void Start(IServer server)
        {
            _sessionContainer = _serviceProvider.GetSessionContainer();
            _timer = new Timer(OnTimerCallback, null, 1000 * _interval, 1000 * _interval);
        }

        private void OnTimerCallback(object state)
        {
            _timer.Change(Timeout.Infinite, Timeout.Infinite);

            try
            {
                Push().GetAwaiter().GetResult();
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception happened in Push().");
            }

            _timer.Change(1000 * _interval, 1000 * _interval);
        }

        private async ValueTask Push()
        {
{'fraction_non_alphanumeric': 0.07213850593138826, 'fraction_numerical': 0.01122154536710484, 'mean_word_length': 2.380281690140845, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670993', 'n_tokens_mistral': 813, 'n_tokens_neox': 756, 'n_words': 188}