//检查连接状态 && (tryTimes++ < 10) public void CheckConnection() { if (_isConnecting) { return;//避免循环递归 } _isConnecting = true; if (!empp.connected) { ConnectResultEnum ret = ConnectResultEnum.CONNECT_AUTH_ERROR; int tryTimes = 0; ret = empp.connect(config.hostIP, config.Port, config.Account, config.PassWord); while (ret != ConnectResultEnum.CONNECT_OK) { tryTimes++; ret = empp.connect(config.hostIP, config.Port, config.Account, config.PassWord); } if (ret != ConnectResultEnum.CONNECT_OK) { _isConnecting = false; throw new Exception("连接登录失败,请检查网络和账号配置。"); } } _isConnecting = false; }
private void CheckConnection() { if (_isConnecting) { return;//避免循环递归 } _isConnecting = true; if (!_ctl.connected) { ConnectResultEnum ret = ConnectResultEnum.CONNECT_AUTH_ERROR; int tryTimes = 0; while (ret != ConnectResultEnum.CONNECT_OK && ret != ConnectResultEnum.CONNECT_KICKLAST && (tryTimes++ < 2)) { Thread.Sleep(3000); ret = _ctl.connect(_config.HostIP, _config.Port, _config.Account, _config.PassWord); } if (ret != ConnectResultEnum.CONNECT_OK && ret != ConnectResultEnum.CONNECT_KICKLAST) { _isConnecting = false; throw new Exception("连接登录失败,请检查网络和账号配置。"); } } _isConnecting = false; }