Esempio n. 1
0
        private async Task AcceptLoopAsync(ISocketConfiguration socketConfiguration, CancellationToken cancellationToken, NodeType nodeType)
        {
            _started.Set();

            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var tcpClient = await _listener.AcceptTcpClientAsync();

                    SetupTcpClientParametersWithoutReceiveTimeout(tcpClient, socketConfiguration);
                    tcpClient.ReceiveTimeout = NodeTypeHasReceiveTimeout.HasReceiveTimeout(nodeType) ? socketConfiguration.ReceiveTimeout.ToMillisOrZero() : 0;

                    var socket = new TcpSocket(_endpoint, tcpClient);
                    socket.Disconnected += () => ClientDisconnected(socket);

                    TryFireClientConnectedEvent(socket, socketConfiguration);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (OperationCanceledException)
            {
            }
            catch (ObjectDisposedException)
            {
            }
            finally
            {
                _stopped.Set();
            }
        }
Esempio n. 2
0
        public void Bind(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration, ClientConnectedDelegate onClientConnected = null, ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (_listener != null || !_stopped.IsSet)
            {
                throw new InvalidOperationException("Server already bound, please use Unbind first");
            }

            var ipAddress = IpAddressFromHostTranslator.GetIpAddressForHost(endpoint.Host);

            _endpoint = endpoint;

            _listener = new TcpListener(ipAddress, endpoint.Port);

            if (onClientConnected != null)
            {
                ClientConnected += onClientConnected;
            }
            if (onClientDisconnected != null)
            {
                ClientDisconnected += onClientDisconnected;
            }

            _stopped.Reset();
            _started.Reset();

            _listener.Start();

            _cts = new CancellationTokenSource();

            StartAcceptLoop(socketConfiguration, _cts.Token, nodeType);
        }
Esempio n. 3
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            var remoteNodeType = NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);

            switch (remoteNodeType)
            {
            case NodeType.ServiceQueueReader:
                ReaderClientConnected(socket, socketConfiguration);
                break;

            case NodeType.ServiceQueueWriter:
                WriterClientConnected(socket, socketConfiguration);
                break;

            default:
                throw new RedFoxProtocolException(String.Format("Unsupported node type connected to ServiceQueue: {0}", remoteNodeType));
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                CheckIfSocketDisconnected(socket);
            }
        }
Esempio n. 4
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);

            var messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(socket);
            var messageQueue       = new MessageQueueBatch(socketConfiguration.SendBufferSize);
            var messageReceiveLoop = new MessageReceiveLoop(_messageSerialization, socket, OnMessageReceived, MessageReceiveLoopOnException);

            if (_broadcastSockets.TryAdd(socket, new MessageQueueReceiveLoop(messageQueue, messageReceiveLoop)))
            {
                _messageQueueBroadcaster.Register(messageQueue, messageFrameWriter);
                ClientConnected(socket, socketConfiguration);
                messageReceiveLoop.Start();
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                SocketDisconnected(socket);
            }
        }
Esempio n. 5
0
        private async Task AcceptLoopAsync(ISocketConfiguration socketConfiguration, CancellationToken cancellationToken, NodeType nodeType)
        {
            _started.Set();

            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var tcpClient = await _listener.AcceptTcpClientAsync();
                    SetupTcpClientParametersWithoutReceiveTimeout(tcpClient, socketConfiguration);
                    tcpClient.ReceiveTimeout = NodeTypeHasReceiveTimeout.HasReceiveTimeout(nodeType) ? socketConfiguration.ReceiveTimeout.ToMillisOrZero() : 0;

                    var socket = new TcpSocket(_endpoint, tcpClient);
                    socket.Disconnected += () => ClientDisconnected(socket);

                    TryFireClientConnectedEvent(socket, socketConfiguration);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (OperationCanceledException)
            {
            }
            catch (ObjectDisposedException)
            {
            }
            finally
            {
                _stopped.Set();
            }
        }
Esempio n. 6
0
        public void Connect(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
        {
            if (socketConfiguration == null)
            {
                throw new ArgumentNullException("socketConfiguration");
            }
            if (_socket != null)
            {
                throw new InvalidOperationException("Subscriber already connected");
            }
            _cts = new CancellationTokenSource();

            _socket = SocketFactory.CreateAndConnectAsync(endpoint, NodeType.Subscriber, socketConfiguration);
            _socket.Disconnected += SocketDisconnected;

            NodeGreetingMessageVerifier.SendReceiveAndVerify(_socket, socketConfiguration.ConnectTimeout);

            if (!_cts.IsCancellationRequested)
            {
                _messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(_socket);

                _messageReceiveLoop = new MessageReceiveLoop(_messageSerialization, _socket, OnMessageReceived, MessageReceiveLoopOnException);
                _messageReceiveLoop.Start();
            }
        }
Esempio n. 7
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);

            var messageFrameWriter   = MessageFrameWriterFactory.CreateWriterFromSocket(socket);
            var messageFrameReceiver = new MessageFrameReceiver(socket);
            var senderReceiver       = new SenderReceiver(messageFrameWriter, messageFrameReceiver);

            socket.Disconnected += () => SocketDisconnected(socket);

            if (_clientSockets.TryAdd(socket, senderReceiver))
            {
                var task = ReceiveRequestMessage(senderReceiver);
                ClientConnected(socket, socketConfiguration);
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                SocketDisconnected(socket);
            }
        }
Esempio n. 8
0
        public void Bind(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration, ClientConnectedDelegate onClientConnected = null, ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (_listener != null || !_stopped.IsSet)
                throw new InvalidOperationException("Server already bound, please use Unbind first");

            var ipAddress = IpAddressFromHostTranslator.GetIpAddressForHost(endpoint.Host);

            _endpoint = endpoint;

            _listener = new TcpListener(ipAddress, endpoint.Port);

            if (onClientConnected != null)
                ClientConnected += onClientConnected;
            if (onClientDisconnected != null)
                ClientDisconnected += onClientDisconnected;

            _stopped.Reset();
            _started.Reset();

            _listener.Start();

            _cts = new CancellationTokenSource();

            StartAcceptLoop(socketConfiguration, _cts.Token, nodeType);
        }
Esempio n. 9
0
        private void ReaderClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            var messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(socket);

            if (_readerClientSockets.TryAdd(socket, messageFrameWriter))
            {
                _messageQueueDistributor.Register(messageFrameWriter);

                ClientConnected(socket, socketConfiguration);
            }
        }
Esempio n. 10
0
 public ISocket CreateAndConnectAsync(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration)
 {
     switch (endpoint.Transport)
     {
         case RedFoxTransport.Inproc:
             return CreateInProcSocket(endpoint);
         case RedFoxTransport.Tcp:
             return CreateTcpSocket(endpoint, nodeType, socketConfiguration);
         default:
             throw new NotSupportedException(String.Format("Transport {0} not supported", endpoint.Transport));
     }
 }
Esempio n. 11
0
        private void WriterClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            var messageFrameReceiver = new MessageFrameReceiver(socket);

            messageFrameReceiver.Disconnected += () => WriterSocketDisconnected(socket);
            var task = ReceiveAsync(messageFrameReceiver, _disposedToken);

            if (_writerClientSockets.TryAdd(socket, messageFrameReceiver))
            {
                ClientConnected(socket, socketConfiguration);
            }
        }
Esempio n. 12
0
        public ISocketAccepter CreateAndBind(RedFoxEndpoint endpoint,
            NodeType nodeType,
            ISocketConfiguration socketConfiguration,
            ClientConnectedDelegate onClientConnected = null,
            ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (socketConfiguration == null) throw new ArgumentNullException("socketConfiguration");

            var server = CreateForTransport(endpoint.Transport);
            server.Bind(endpoint, nodeType, socketConfiguration, onClientConnected, onClientDisconnected);
            return server;
        }
Esempio n. 13
0
 private bool TryFireClientConnectedEvent(ISocket socket, ISocketConfiguration socketConfiguration)
 {
     try
     {
         ClientConnected(socket, socketConfiguration);
         return(true);
     }
     catch
     {
         // TODO: log exception somewhere
         return(false);
     }
 }
 private bool TryFireClientConnectedEvent(InProcSocket socket, ISocketConfiguration socketConfiguration)
 {
     try
     {
         socket.Disconnected += () => ClientDisconnected(socket);
         ClientConnected(socket, socketConfiguration);
         return true;
     }
     catch
     {
         return false;
     }
 }
 private bool TryFireClientConnectedEvent(InProcSocket socket, ISocketConfiguration socketConfiguration)
 {
     try
     {
         socket.Disconnected += () => ClientDisconnected(socket);
         ClientConnected(socket, socketConfiguration);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 16
0
 public SocketBase(ISocketConfiguration configuration)
 {
     _configuration = configuration;
     if (configuration.Autoconnect)
     {
         CyclicExecutor.Instance.Add(_cycleId, _cycleId, 5000, () =>
         {
             CyclicExecutor.Instance.Enabled(_cycleId, false);
             if (!IsConnected && !_shutdown)
             {
                 Open();
             }
         });
     }
 }
Esempio n. 17
0
        public void Connect(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
        {
            if (socketConfiguration == null) throw new ArgumentNullException("socketConfiguration");
            if (_socket != null) throw new InvalidOperationException("Subscriber already connected");
            _cts = new CancellationTokenSource();

            _socket = SocketFactory.CreateAndConnectAsync(endpoint, NodeType.ServiceQueueWriter, socketConfiguration);
            _socket.Disconnected += SocketDisconnected;

            NodeGreetingMessageVerifier.SendReceiveAndVerify(_socket, socketConfiguration.ConnectTimeout);

            if (!_cts.IsCancellationRequested)
            {
                _messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(_socket);
            }
        }
Esempio n. 18
0
        public ISocketAccepter CreateAndBind(RedFoxEndpoint endpoint,
                                             NodeType nodeType,
                                             ISocketConfiguration socketConfiguration,
                                             ClientConnectedDelegate onClientConnected       = null,
                                             ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (socketConfiguration == null)
            {
                throw new ArgumentNullException("socketConfiguration");
            }

            var server = CreateForTransport(endpoint.Transport);

            server.Bind(endpoint, nodeType, socketConfiguration, onClientConnected, onClientDisconnected);
            return(server);
        }
Esempio n. 19
0
        private static ISocket CreateTcpSocket(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration)
        {
            var hasReceiveTimeout = NodeTypeHasReceiveTimeout.HasReceiveTimeout(nodeType);

            var tcpClient = new TcpClient
            {
                ReceiveTimeout = hasReceiveTimeout ? socketConfiguration.ReceiveTimeout.ToMillisOrZero() : 0,
                SendTimeout = socketConfiguration.SendTimeout.ToMillisOrZero(),

                NoDelay = true,
                ReceiveBufferSize = socketConfiguration.ReceiveBufferSize,
                SendBufferSize = socketConfiguration.SendBufferSize
            };
            ConnectTcpSocket(tcpClient, endpoint.Host, endpoint.Port, socketConfiguration.ConnectTimeout);

            return new TcpSocket(endpoint, tcpClient);
        }
        public void Bind(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration, ClientConnectedDelegate onClientConnected = null, ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (_listener != null || !_stopped.IsSet)
                throw new InvalidOperationException("Server already bound, please use Unbind first");

            _listener = InProcessEndpoints.Instance.RegisterAccepter(endpoint);
            _endpoint = endpoint;

            if (onClientConnected != null)
                ClientConnected += onClientConnected;
            if (onClientDisconnected != null)
                ClientDisconnected += onClientDisconnected;

            _started.Reset();
            _cts = new CancellationTokenSource();
            Task.Factory.StartNew(() => StartAcceptLoop(_cts.Token, socketConfiguration), TaskCreationOptions.LongRunning);
            _started.Wait();
        }
        private void StartAcceptLoop(CancellationToken cancellationToken, ISocketConfiguration socketConfiguration)
        {
            _stopped.Reset();
            _started.Set();

            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var socketPair = _listener.Take(cancellationToken);
                    TryFireClientConnectedEvent(socketPair.ServerSocket, socketConfiguration);
                }
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                _stopped.Set();
            }
        }
        private void StartAcceptLoop(CancellationToken cancellationToken, ISocketConfiguration socketConfiguration)
        {
            _stopped.Reset();
            _started.Set();

            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var socketPair = _listener.Take(cancellationToken);
                    TryFireClientConnectedEvent(socketPair.ServerSocket, socketConfiguration);
                }
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                _stopped.Set();
            }
        }
Esempio n. 23
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null) throw new ArgumentNullException("socket");

            var remoteNodeType = NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);
            switch (remoteNodeType)
            {
                case NodeType.ServiceQueueReader:
                    ReaderClientConnected(socket, socketConfiguration);
                    break;
                case NodeType.ServiceQueueWriter:
                    WriterClientConnected(socket, socketConfiguration);
                    break;
                default:
                    throw new RedFoxProtocolException(String.Format("Unsupported node type connected to ServiceQueue: {0}", remoteNodeType));
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                CheckIfSocketDisconnected(socket);
            }
        }
Esempio n. 24
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null) throw new ArgumentNullException("socket");

            NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);

            var messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(socket);
            var messageQueue = new MessageQueueBatch(socketConfiguration.SendBufferSize);
            var messageReceiveLoop = new MessageReceiveLoop(_messageSerialization, socket, OnMessageReceived, MessageReceiveLoopOnException);

            if (_broadcastSockets.TryAdd(socket, new MessageQueueReceiveLoop(messageQueue, messageReceiveLoop)))
            {
                _messageQueueBroadcaster.Register(messageQueue, messageFrameWriter);
                ClientConnected(socket, socketConfiguration);
                messageReceiveLoop.Start();
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                SocketDisconnected(socket);
            }
        }
        public void Bind(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration, ClientConnectedDelegate onClientConnected = null, ClientDisconnectedDelegate onClientDisconnected = null)
        {
            if (_listener != null || !_stopped.IsSet)
            {
                throw new InvalidOperationException("Server already bound, please use Unbind first");
            }

            _listener = InProcessEndpoints.Instance.RegisterAccepter(endpoint);
            _endpoint = endpoint;

            if (onClientConnected != null)
            {
                ClientConnected += onClientConnected;
            }
            if (onClientDisconnected != null)
            {
                ClientDisconnected += onClientDisconnected;
            }

            _started.Reset();
            _cts = new CancellationTokenSource();
            Task.Factory.StartNew(() => StartAcceptLoop(_cts.Token, socketConfiguration), TaskCreationOptions.LongRunning);
            _started.Wait();
        }
Esempio n. 26
0
        private void OnClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            if (socket == null) throw new ArgumentNullException("socket");

            NodeGreetingMessageVerifier.SendReceiveAndVerify(socket, socketConfiguration.ConnectTimeout);

            var messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(socket);
            var messageFrameReceiver = new MessageFrameReceiver(socket);
            var senderReceiver = new SenderReceiver(messageFrameWriter, messageFrameReceiver);

            socket.Disconnected += () => SocketDisconnected(socket);

            if (_clientSockets.TryAdd(socket, senderReceiver))
            {
                var task = ReceiveRequestMessage(senderReceiver);
                ClientConnected(socket, socketConfiguration);
            }

            if (socket.IsDisconnected)
            {
                // this is to fix the race condition if socket was disconnected meanwhile
                SocketDisconnected(socket);
            }
        }
Esempio n. 27
0
 public void Bind(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
 {
     var server = SocketAccepterFactory.CreateAndBind(endpoint, NodeType.Responder, socketConfiguration, OnClientConnected);
     _servers[endpoint] = server;
 }
Esempio n. 28
0
        public void Bind(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
        {
            var server = SocketAccepterFactory.CreateAndBind(endpoint, NodeType.Responder, socketConfiguration, OnClientConnected);

            _servers[endpoint] = server;
        }
Esempio n. 29
0
        private void ReaderClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            var messageFrameWriter = MessageFrameWriterFactory.CreateWriterFromSocket(socket);

            if (_readerClientSockets.TryAdd(socket, messageFrameWriter))
            {
                _messageQueueDistributor.Register(messageFrameWriter);

                ClientConnected(socket, socketConfiguration);
            }
        }
Esempio n. 30
0
        private static void SetupTcpClientParametersWithoutReceiveTimeout(TcpClient tcpClient, ISocketConfiguration socketConfiguration)
        {
            tcpClient.SendTimeout = socketConfiguration.SendTimeout.ToMillisOrZero();

            tcpClient.NoDelay = true;
            tcpClient.ReceiveBufferSize = socketConfiguration.ReceiveBufferSize;
            tcpClient.SendBufferSize = socketConfiguration.SendBufferSize;
        }
Esempio n. 31
0
 private bool TryFireClientConnectedEvent(ISocket socket, ISocketConfiguration socketConfiguration)
 {
     try
     {
         ClientConnected(socket, socketConfiguration);
         return true;
     }
     catch
     {
         // TODO: log exception somewhere
         return false;
     }
 }
Esempio n. 32
0
        public ISocket CreateAndConnectAsync(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration)
        {
            switch (endpoint.Transport)
            {
            case RedFoxTransport.Inproc:
                return(CreateInProcSocket(endpoint));

            case RedFoxTransport.Tcp:
                return(CreateTcpSocket(endpoint, nodeType, socketConfiguration));

            default:
                throw new NotSupportedException(String.Format("Transport {0} not supported", endpoint.Transport));
            }
        }
Esempio n. 33
0
 private void StartAcceptLoop(ISocketConfiguration socketConfiguration, CancellationToken cancellationToken, NodeType nodeType)
 {
     var task = AcceptLoopAsync(socketConfiguration, cancellationToken, nodeType);
 }
Esempio n. 34
0
 public void Bind(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
 {
     var server = SocketAccepterFactory.CreateAndBind(endpoint, NodeType.ServiceQueue, socketConfiguration, OnClientConnected, CheckIfSocketDisconnected);
     _servers[endpoint] = server;
 }
Esempio n. 35
0
 public SocketBase(ISocketConfiguration configuration)
 {
     _configuration = configuration;
 }
Esempio n. 36
0
        public void Bind(RedFoxEndpoint endpoint, ISocketConfiguration socketConfiguration)
        {
            var server = SocketAccepterFactory.CreateAndBind(endpoint, NodeType.ServiceQueue, socketConfiguration, OnClientConnected, CheckIfSocketDisconnected);

            _servers[endpoint] = server;
        }
Esempio n. 37
0
 private void StartAcceptLoop(ISocketConfiguration socketConfiguration, CancellationToken cancellationToken, NodeType nodeType)
 {
     var task = AcceptLoopAsync(socketConfiguration, cancellationToken, nodeType);
 }
Esempio n. 38
0
        private static void SetupTcpClientParametersWithoutReceiveTimeout(TcpClient tcpClient, ISocketConfiguration socketConfiguration)
        {
            tcpClient.SendTimeout = socketConfiguration.SendTimeout.ToMillisOrZero();

            tcpClient.NoDelay           = true;
            tcpClient.ReceiveBufferSize = socketConfiguration.ReceiveBufferSize;
            tcpClient.SendBufferSize    = socketConfiguration.SendBufferSize;
        }
Esempio n. 39
0
        private static ISocket CreateTcpSocket(RedFoxEndpoint endpoint, NodeType nodeType, ISocketConfiguration socketConfiguration)
        {
            var hasReceiveTimeout = NodeTypeHasReceiveTimeout.HasReceiveTimeout(nodeType);

            var tcpClient = new TcpClient
            {
                ReceiveTimeout = hasReceiveTimeout ? socketConfiguration.ReceiveTimeout.ToMillisOrZero() : 0,
                SendTimeout    = socketConfiguration.SendTimeout.ToMillisOrZero(),

                NoDelay           = true,
                ReceiveBufferSize = socketConfiguration.ReceiveBufferSize,
                SendBufferSize    = socketConfiguration.SendBufferSize
            };

            ConnectTcpSocket(tcpClient, endpoint.Host, endpoint.Port, socketConfiguration.ConnectTimeout);

            return(new TcpSocket(endpoint, tcpClient));
        }
Esempio n. 40
0
        private void WriterClientConnected(ISocket socket, ISocketConfiguration socketConfiguration)
        {
            var messageFrameReceiver = new MessageFrameReceiver(socket);
            messageFrameReceiver.Disconnected += () => WriterSocketDisconnected(socket);
            var task = ReceiveAsync(messageFrameReceiver, _disposedToken);

            if (_writerClientSockets.TryAdd(socket, messageFrameReceiver))
            {
                ClientConnected(socket, socketConfiguration);
            }
        }