Пример #1
0
        private Task WriteConnectionStatusAsync(CancellationToken cancellationToken)
        {
            return(Task.Run(async() =>
            {
                var peakConnections = 0;
                while (!cancellationToken.IsCancellationRequested)
                {
                    var statusDictionary = _agent.GetWorkerStatus();

                    // Total things up
                    var status = new StatusInformation();
                    foreach (var value in statusDictionary.Values)
                    {
                        status = status.Add(value);
                    }

                    peakConnections = Math.Max(peakConnections, status.ConnectedCount);
                    status.PeakConnections = peakConnections;

                    Trace.WriteLine(JsonConvert.SerializeObject(status));

                    await Task.Delay(1000);
                }
            }));
        }
Пример #2
0
        public Task StatusAsync(
            int id,
            StatusInformation statusInformation)
        {
            if (_workers.TryGetValue(id, out var worker))
            {
                worker.StatusInformation = statusInformation;
            }

            return(Task.CompletedTask);
        }
Пример #3
0
        public async Task StatusAsync(
            int id,
            StatusInformation statusInformation)
        {
            var parameters = new
            {
                Id = id,
                StatusInformation = statusInformation
            };

            await SendAsync("status", JToken.FromObject(parameters));;
        }