Ejemplo n.º 1
0
        private void sockServer_OnRequestReceived(object sender, MessageEventArgs args)
        {
            try
            {
                string message    = args.Message;
                string serverName = message.Substring(21).Trim();

                logger.Info("Recebeu login [" + message + "]");

                lock (dctClientes)
                {
                    if (dctClientes.ContainsKey(args.ClientNumber))
                    {
                        HomeBrokerHandlerState state = dctClientes[args.ClientNumber];

                        state.HandlerNegocios.Start();
                        state.HandlerLivroOfertas.Start();
                        state.HandlerLivroAgregado.Start();

                        state.HandlerNegocios.TratarServicoCotacaoLogin(serverName);
                        state.HandlerLivroOfertas.TratarServicoCotacaoLogin(serverName);
                        state.HandlerLivroAgregado.TratarServicoCotacaoLogin(serverName);
                    }
                    else
                    {
                        logger.Error("ClientNumber nao encontrado [" + args.ClientNumber + "]");
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("sockServer_OnRequestReceived(): " + ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
        private void sockServer_OnClientDisconnected(object sender, ClientDisconnectedEventArgs args)
        {
            if (dctClientes.ContainsKey(args.ClientNumber))
            {
                logger.Info("Cliente [" + args.ClientNumber + "] desconectou");

                HomeBrokerHandlerState state = dctClientes[args.ClientNumber];

                state.HandlerLivroOfertas.Stop();
                state.HandlerNegocios.Stop();
                state.HandlerLivroAgregado.Stop();

                dctClientes.Remove(args.ClientNumber);
            }
        }
Ejemplo n.º 3
0
        private void sockServer_OnClientConnected(object sender, ClientConnectedEventArgs args)
        {
            lock (dctClientes)
            {
                logger.Info("Cliente [" + args.ClientNumber + "] [" + args.ClientSocket.RemoteEndPoint.ToString() + "]");

                HomeBrokerHandlerState state = new HomeBrokerHandlerState();

                state.ClientNumber         = args.ClientNumber;
                state.ClientSocket         = args.ClientSocket;
                state.HandlerLivroOfertas  = new HomeBrokerHandlerLivroOfertas(args.ClientNumber, args.ClientSocket);
                state.HandlerNegocios      = new HomeBrokerHandlerNegocios(args.ClientNumber, args.ClientSocket);
                state.HandlerLivroAgregado = new HomeBrokerHandlerLivroOfertaAgregado(args.ClientNumber, args.ClientSocket);

                dctClientes.Add(args.ClientNumber, state);
            }
        }