/// <summary> /// 当用服务信息连接失败处理 /// </summary> /// <param name="ex">异常信息</param> /// <param name="errMsg">错误提示</param> /// <param name="svrInfo">服务信息</param> /// <param name="connService">失败的连接服务</param> private void OnOpenConnectionWithSvrInfoFail(Exception ex, string errMsg, PtServerInfo svrInfo, ConnectService failConnService) { SvLogger.Error("Open Connection ServerInfo Fail : SvrType={0}, IP={1}, Port={2}, ErrMsg={3}.", svrInfo.m_Type, svrInfo.m_Address, svrInfo.m_Port, errMsg); //重连 ConnectIPPort ipPort = new ConnectIPPort(m_ip, m_port); SIReconnectManager.Instance.AddReconnectInfo(ipPort); SIConnServiceManager.Instance.RemoveConnService(m_id); }
/// <summary> /// 当服务组连接断开 /// </summary> /// <param name="sessionID">服务组连接sessionID</param> private void OnServerConnectionClose(ConnectionSession connSesion) { PtServerInfo svrInfo = null; if (m_connService.GetConnectServerInfo(ref svrInfo)) { ReconnectServerInfo reconnSvrInfo = new ReconnectServerInfo(svrInfo); SIReconnectManager.Instance.AddReconnectInfo(reconnSvrInfo); } else { ConnectIPPort ipPort = new ConnectIPPort(m_ip, m_port); SIReconnectManager.Instance.AddReconnectInfo(ipPort); } SIConnServiceManager.Instance.RemoveConnService(m_id); }
public void Update(int curSvrTime) { while (m_reconnSvrInfoList.First != null) { if (m_reconnSvrInfoList.First.Value.ReconnectTime < curSvrTime) { //重连 if (SIConnServiceManager.Instance.CreateConnService(m_reconnSvrInfoList.First.Value.m_SvrInfo) == false) { LinkedListNode <ReconnectServerInfo> reconnSvrInfoNode = m_reconnSvrInfoList.First; ReconnectServerInfo newInfo = new ReconnectServerInfo(reconnSvrInfoNode.Value.m_SvrInfo); m_reconnSvrInfoList.AddLast(newInfo); } m_reconnSvrInfoList.RemoveFirst(); } else { break; } } while (m_reconnIPPortList.First != null) { if (m_reconnIPPortList.First.Value.ReconnectTime < curSvrTime) { //重连 if (SIConnServiceManager.Instance.CreateConnService(m_reconnIPPortList.First.Value.m_IP, m_reconnIPPortList.First.Value.m_Port) == false) { LinkedListNode <ConnectIPPort> reconnIPPortNode = m_reconnIPPortList.First; ConnectIPPort newInfo = new ConnectIPPort(reconnIPPortNode.Value.m_IP, reconnIPPortNode.Value.m_Port); m_reconnIPPortList.AddLast(newInfo); } m_reconnIPPortList.RemoveFirst(); } else { break; } } }
public void AddReconnectInfo(ConnectIPPort reconnIPPort) { m_reconnIPPortList.AddLast(reconnIPPort); }