Exemplo n.º 1
0
        public void TryUserConnectToServer(UserConReq conReq)
        {
            //changed 2018-03-29
            try
            {
                int connId = conReq.ConnNum;

                if (!_dictTCPClients.ContainsKey(connId))
                {
                    AddTCPCleintAndDataReciever(connId);

                    bool bSuccess = TryConnectToServer(connId);
                    //Connection attempt was not sucesss
                    if (!bSuccess)
                    {
                        RemoveTCPClientAndReciever(connId);
                        OnUnsuccessfullConnectTrial(conReq, connId);

                        IsEnabledUserConnectionToServer = true;

                        return; //if server unavailable - exit
                    }
                }

                //if available send auth request to server
                SendAuthRequest(connId, conReq.AuthRequest);
            }
            catch (Exception e)
            {
                Error("CBaseCommunicator.TryUserConnectToServer", e);
            }
        }
        public ControlAuthForm()
        {
            InitializeComponent();
            this.DataContext = this;

            ParamInst = new UserConReq();
        }
Exemplo n.º 3
0
 protected override void OnUnsuccessfullConnectTrial(UserConReq conReq, int connId)
 {
     _kernelTerminal.ViewModelDispatcher.
     Update(new CAuthResponse()
     {
         IsSuccess    = false,
         ErrorMessage = "Сервер недоступен" + conReq.ServerName
     }, connId);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Automatic connection sequence entry point.
        ///
        /// Call from MainWindow.MainWindow_Loaded
        ///
        /// </summary>
        public void AutoConnection()
        {
            List <CServer> servers = Communicator.ServersConf.Servers;

            for (int i = 0; i < servers.Count; i++)
            {
                string serverName = Communicator.ServersConf.Servers[i].Name;
                //UserConReq req =  _passwordSaver.GetUserConReq(i);
                UserConReq req = new UserConReq
                {
                    AuthRequest = _passwordSaver.GetUserAuthReq(i),
                    ConnNum     = i,
                    ServerName  = serverName
                };


                if (req == null)
                {
                    continue;
                }
                //System.Threading.Thread.Sleep(20000);
                ConnectionTrial(req);
            }
        }
Exemplo n.º 5
0
 protected override void OnUnsuccessfullConnectTrial(UserConReq conReq, int connId)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public override void OnUserTryConnectToServer(UserConReq authReq)
 {
     base.OnUserTryConnectToServer(authReq);
     _passwordSaver.OnConnectionTrial(authReq);
 }
Exemplo n.º 7
0
 public virtual void OnUserTryConnectToServer(UserConReq authReq)
 {
     IsEnabledUserConnectionToServer = false;
     TryUserConnectToServer(authReq);
 }
Exemplo n.º 8
0
 protected abstract void OnUnsuccessfullConnectTrial(UserConReq conReq, int connId);
Exemplo n.º 9
0
 /// <summary>
 /// On each connection trial remember UserConReq struct
 /// </summary>
 /// <param name="userConReq"></param>
 public void OnConnectionTrial(UserConReq userConReq)
 {
     _lastUserConReq = userConReq;
 }