Ejemplo n.º 1
0
 /// <summary>
 /// 重连模块
 /// </summary>
 private void reconnect()
 {
     if (_reconnectMax == 0)
     {
         return;    //不重连直接返回
     }
     reconnectCi++; //每重连一次重连的次数加1
     if (stateOne != null)
     {
         stateOne.WorkSocket.Close();
         stateOne = null;
     }
     if (reconnectOn == false)
     {
         reconnectOn = true;
         CommonMethod.eventInvoket(() => { ReconnectionStart(); });
     }
     _engineStart = false;
     StartEngine();//调用启动引擎
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 登录失败之后要处理的事情
 /// </summary>
 private void loginFailure(string str)
 {
     outtimebool = true;       //登录有结果了,判断超时的线程跳出
     if (_engineStart == true) //失败的时候引擎都是关闭的
     {
         return;
     }
     if (reconnectOn && reconnectCi < _reconnectMax)
     {
         reconnect();//继续重连
     }
     else
     {
         if (reconnectOn)
         {
             CommonMethod.eventInvoket(() => { StartResult(false, "重连失败" + str); });
         }
         else
         {
             CommonMethod.eventInvoket(() => { StartResult(false, str); });
         }
         CloseEngine();//不重连了就关闭客户端,释放资源
     }//登录失败触发此事件
 }