Пример #1
0
        private void wardenClient_ClientDisconnected(WardenClient wardenClient)
        {
            try
            {
                wardenClient.ClientDisconnected -= wardenClient_ClientDisconnected;

                Task clientReadTask;
                if (wardenClientProcessMessageTasks.TryGetValue(wardenClient, out clientReadTask))
                {
                    if (clientReadTask.Exception != null)
                    {
                        var flattened = clientReadTask.Exception.Flatten();
                        log.WarnException(String.Format("Client '{0}' exceptions!", wardenClient.ID), flattened);
                    }
                }

                wardenClient.Dispose();
            }
            catch (Exception ex)
            {
                log.ErrorException(ex);
            }

            log.Trace("Client {0} disconnected", wardenClient.ID);
        }
Пример #2
0
        public void ClientConnected(TcpClient client)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            var wardenClient = new WardenClient(client, containerManager, jobManager, cancellationToken);

            wardenClient.ClientDisconnected += wardenClient_ClientDisconnected;

            // Save the Resulting task from ReceiveInput as a Task so
            // we can check for any unhandled exceptions that may have occured
            wardenClientProcessMessageTasks.Add(wardenClient, wardenClient.ProcessMessages());

            wardenClients.Add(wardenClient);
            log.Trace("Client {0} Connected", wardenClient.ID);
        }