Beispiel #1
0
        public void Start()
        {
            var logger = new Logger();

            ServerConnection serverConnection;

            try
            {
                serverConnection = new ServerConnection();
            }
            catch
            {
                logger.PostException("Can't connect to the server!");
                return;
            }
            var sender   = new Sender(serverConnection, logger);
            var recivier = new Recivier(serverConnection, logger);

            new Thread(() => recivier.listen()).Start();

            var authorizator = new Authorizator(logger, sender);

            recivier.MessageCame += authorizator.MessageCame;
            authorizator.Authorize();
            if (authorizator.IsAuthorized())
            {
                logger.Post("Success authorization!");
            }
            recivier.MessageCame -= authorizator.MessageCame;
            var connectionChecker = new ConnectionChecker(sender);

            connectionChecker.Start();
            var chatCore = new ChatCore(sender, logger, connectionChecker);

            recivier.MessageCame += chatCore.MessageCame;
            connectionChecker.ConnectionProblem += chatCore.ConnectionProblem;
            var inputHandler = new InputHandler(logger);

            inputHandler.MessageEntered += chatCore.MessageEntered;
            inputHandler.start();
        }
Beispiel #2
0
        /// <summary>
        /// Cierra la sesion
        /// </summary>
        /// <param name="security">Contexto de seguridad</param>
        private void CloseSession(SecurityContext security)
        {
            Authorizator authorizator = new Authorizator();

            authorizator.CloseSession(security);
        }
Beispiel #3
0
        /// <summary>
        /// Autentica un usuario
        /// </summary>
        /// <param name="requestAuthorization">Request authorization</param>
        /// <returns>Contexto de seguridad</returns>
        private GenericResponse <SecurityContext> Authorize(RequestAuthorization requestAuthorization)
        {
            Authorizator authorizator = new Authorizator();

            return(authorizator.Authenticate(requestAuthorization));
        }