Example #1
0
        private void StartListening()
        {
            while (true)
            {
                var client = _server.AcceptTcpClient();
                _tcpConnectionHandler.HandleConnection(client);
                // var connection = new ClientConnection(client);
                // var connectionHandler = new ClientConnectionHandler(connection);
                // var name = connectionHandler.Receive();

                // _connectedUsers.Add(new UserConnection(name, connection));

                // connectionHandler.OnMessageReceived += connectionHandler_OnMessageReceived;
                // connectionHandler.StartListening();
            }
        }
            protected override void HandleConnection(AmqpConnection connection)
            {
                try
                {
                    Fx.Assert(connection.Settings.RemoteHostName != null, "RemoteHostName cannot be null. It has been validated in OnConnectionOpen.");
                    IConnectionHandler handler = null;
                    if (!this.connectionHandlers.TryGetValue(connection.Settings.RemoteHostName, out handler))
                    {
                        throw new AmqpException(AmqpError.NotFound, SR.AmqpConnectionHandlerNotFound(connection.Settings.RemoteHostName));
                    }

                    handler.HandleConnection(connection);
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }

                    throw ExceptionHelper.ToAmqpException(exception);
                }
            }