Browse Source

Z991239-5017 #comment 优化实体连接流程

80274480 1 year ago
parent
commit
ae3db8a788

+ 4 - 0
Module/mod_agentip/mod_agentip.cpp

@@ -59,6 +59,10 @@ public:
 		if (Error_Succeed == ConnectAssistChannel()) {
 			m_bConnectAssist = TRUE;
 		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+			GetFunction()->SetTimer(1, this, 3150);
+		}
 	}
 
 	virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,

+ 1 - 1
Module/mod_counterconnector/ConnectorFSM.h

@@ -43,7 +43,7 @@ using namespace InteractionContext;
 
 
 #ifndef RVC_DEFAULT_HTTPTIMEOUT
-#define RVC_DEFAULT_HTTPTIMEOUT 5
+#define RVC_DEFAULT_HTTPTIMEOUT 10
 #endif // !RVC_DEFAULT_HTTPTIMEOUT
 
 

+ 12 - 5
Module/mod_counterconnector/mod_counterconnector.cpp

@@ -121,6 +121,9 @@ void CCounterConnectorEntity::OnStarted()
 	if (Error_Succeed == ConnectAssistChannel()){
 		m_bConnectAssist = TRUE;
 	}
+	else {
+		GetFunction()->SetTimer(1, this, 3600);
+	}
 
 	if (m_fsm.ReConnectionAssistchan()){
 		m_fsm.m_bConAssist = TRUE;
@@ -263,9 +266,11 @@ ErrorCodeEnum CCounterConnectorEntity::LoadEntityConfig()
 
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Call Route Type is %d,and PickUp Call Type is %d.",m_iRouteType, m_iPickUpCallType);
 
-	char strmsg[MAX_PATH] = { 0 };
-	snprintf(strmsg, MAX_PATH, "call route type is %d.", m_iRouteType);
-	LogWarn(Severity_Low, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_TYPE, strmsg);
+	if (1 != m_iRouteType) {
+		char strmsg[MAX_PATH] = { 0 };
+		snprintf(strmsg, MAX_PATH, "call route type is %d.", m_iRouteType);
+		LogWarn(Severity_Low, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_TYPE, strmsg);
+	}
 
 	return Error;
 }
@@ -581,8 +586,10 @@ bool CCounterConnectorEntity ::IsService() const
 void CCounterConnectorEntity::OnTimeout(DWORD dwTimerID)
 {
 	if (1 == dwTimerID){
-		if (Error_Succeed == ConnectAssistChannel()) {
-			m_bConnectAssist = TRUE;
+		if (FALSE == m_bConnectAssist) {
+			if (Error_Succeed == ConnectAssistChannel()) {
+				m_bConnectAssist = TRUE;
+			}
 		}
 
 		if (TRUE == m_bConnectAssist) {

+ 8 - 2
Module/mod_countercontext/mod_countercontext.cpp

@@ -84,6 +84,10 @@ public:
 		if (Error_Succeed == ConnectAssistChannel()) {
 			m_bConnectAssist = TRUE;
 		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+			GetFunction()->SetTimer(1, this, 3150);
+		}
 	}
 
 	ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
@@ -176,8 +180,10 @@ public:
 	void OnTimeout(DWORD dwTimerID)
 	{
 		if (1 == dwTimerID) {
-			if (Error_Succeed == ConnectAssistChannel()) {
-				m_bConnectAssist = TRUE;
+			if (FALSE == m_bConnectAssist) {
+				if (Error_Succeed == ConnectAssistChannel()) {
+					m_bConnectAssist = TRUE;
+				}
 			}
 
 			if (TRUE == m_bConnectAssist) {

+ 184 - 79
Module/mod_initiativetransfer/FlowControlFSM.cpp

@@ -2,14 +2,30 @@
 #include "FlowControlFSM.h"
 
 #define LOG_EVT_EXIT_ACM_FLOW	 0x30500002          //退出坐席控制流程
+//错误码
+#define LOG_ERR_S0_ANSACMFLOW	 			0x30500080          
+#define LOG_ERR_S0_REQAGENTFLOW	 			0x30500081  
+#define LOG_ERR_S1_REQAGENTFLOW_FAILED 		0x30500082
+#define LOG_ERR_S2_ANSAGENTFLOW_FAILED	 	0x30500083
+#define LOG_ERR_S2_NTFENTFLOW_FAILED	 	0x30500084
+#define LOG_ERR_S3_ANSACMFLOW_FAILED	 	0x30500085
+#define LOG_ERR_S5_DISCTRL_FAILED 			0x30500086
+#define LOG_ERR_S5_REQAGENTFLOW_FAILED 		0x30500087
+#define LOG_ERR_S7_ENTRY 					0x30500088
+#define LOG_ERR_S1_ASSIS_IDEL	 			0x30500089
+#define LOG_ERR_S2_ASSIS_IDEL	 			0x3050008a
+#define LOG_ERR_S3_ASSIS_IDEL	 			0x3050008b
+#define LOG_ERR_S5_ASSIS_IDEL	 			0x3050008c
+#define LOG_EVT_CONNEC_ASSISTCHAN_FAILED	0x3050008d
+
 
 void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData )
 {
-	LOG_FUNCTION();
 	if (Error == Error_Succeed) {
 		if (Msg.state == eChannelState_Connected) {
 			m_pFSM->PostEventFIFO(new FSMEvent(USER_EVT_CHAN_ON));
-		} else if (Msg.state == eChannelState_Idle) {
+		} 
+		else if (Msg.state == eChannelState_Idle) {
 			m_pFSM->PostEventFIFO(new FSMEvent(USER_EVT_CHAN_OFF));
 		}
 	}
@@ -17,7 +33,6 @@ void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_State_Info &M
 
 void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
 {
-	LOG_FUNCTION();
 	if (Error == Error_Succeed) {
 		m_pFSM->ProcessPacket(Msg.sub_type, Msg.data);
 	}
@@ -59,34 +74,13 @@ void CFlowControlFSM::OnStateTrans( int iSrcState, int iDstState )
 
 ErrorCodeEnum CFlowControlFSM::OnInit()
 {
-	//ErrorCodeEnum Error;
-	//m_pClient = new ChannelClient(m_pEntity, this);
-	//Error = m_pClient->Connect();
-	//if (Error == Error_Succeed) {
-	//	ChannelService_BeginState_Sub StateSub;
-	//	Error = m_pClient->BeginState(StateSub);
-	//	if (Error == Error_Succeed) {
-	//		ChannelService_BeginRecv_Sub Sub;
-	//		Sub.type = ACM_TYPE_FLW;
-	//		Error = m_pClient->BeginRecv(Sub);
-	//	}
-	//	if (Error != Error_Succeed) {
-	//		m_pClient->GetFunction()->CloseSession();
-	//		m_pClient->SafeDelete();
-	//		m_pClient = NULL;
-	//	}
-	//} else {
-	//	m_pClient->SafeDelete();
-	//	m_pClient = NULL;
-	//}
-
-	//if (Error == Error_Succeed) 
-	//{
-		AddStateHooker(this);
-	//}
-	
+	m_bConnectAssit = false;
+		
+	AddStateHooker(this);
+
 	return Error_Succeed;
 }
+
 ErrorCodeEnum CFlowControlFSM::OnExit()
 { 
 	if (m_pClient != NULL) {
@@ -103,84 +97,163 @@ ErrorCodeEnum CFlowControlFSM::OnExit()
 	return Error_Succeed;
 }
 
-BOOL CFlowControlFSM::ReConnectionAssistchan()
+//BOOL CFlowControlFSM::ReConnectionAssistchan()
+//{
+//	if (m_pClient != NULL){
+//		m_pClient->GetFunction()->CloseSession();
+//		m_pClient = NULL;
+//		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Close AssistChannel Session ");
+//	}
+//
+//	if (m_pClient == NULL)
+//	{
+//		ErrorCodeEnum Error;
+//		m_pClient = new ChannelClient(m_pEntity, this);
+//		Error = m_pClient->Connect();
+//		if (Error != Error_Succeed) {
+//			m_pClient = NULL;
+//			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_channelClient connect fail!");
+//			return FALSE;
+//		}
+//		else{
+//			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_channelClient connect success!");
+//		}
+//
+//		if(Error == Error_Succeed)
+//		{
+//			ChannelService_BeginState_Sub ChannelSub;
+//			Error = m_pClient->BeginState(ChannelSub);
+//			if (Error != Error_Succeed) 
+//			{
+//				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel failed!");
+//				m_pClient->GetFunction()->CloseSession();
+//				m_pClient = NULL;
+//				return FALSE;
+//			}
+//			else{
+//				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel success!");
+//			}
+//		}
+//
+//		if(Error == Error_Succeed)
+//		{
+//			ChannelService_BeginRecv_Sub Sub;
+//			Sub.type = ACM_TYPE_FLW;
+//			Error = m_pClient->BeginRecv(Sub);
+//			if (Error != Error_Succeed) 
+//			{
+//				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Register ACM_TYPE_FLW failed!");
+//				m_pClient->GetFunction()->CloseSession();
+//				m_pClient = NULL;
+//				return FALSE;
+//			}
+//			else{
+//				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Register ACM_TYPE_FLW success!");
+//			}
+//		}
+//	}
+//
+//	return TRUE;
+//}
+
+bool CFlowControlFSM::IsAssistchanEntityAvailable()
 {
-	if (m_pClient != NULL)
-	{
-		m_pClient->GetFunction()->CloseSession();
-		m_pClient = NULL;
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Close AssistChannel Session ");
+	if (Error_Succeed == ConnectToAssistchan()) {
+		return true;
 	}
+	else {
+		return false;
+	}
+}
 
-	if (m_pClient == NULL)
-	{
-		ErrorCodeEnum Error;
+ErrorCodeEnum CFlowControlFSM::ConnectToAssistchan(bool blogevt)
+{
+	if (!IsAssistchanConnectSessionOK()) {
+		FreeAssistchanClient();
 		m_pClient = new ChannelClient(m_pEntity, this);
-		Error = m_pClient->Connect();
-		if (Error != Error_Succeed) 
-		{
+		ErrorCodeEnum errorCode = m_pClient->Connect();
+		if (Error_Succeed != errorCode) {
+			m_pClient->SafeDelete();
 			m_pClient = NULL;
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_channelClient connect fail!");
-			return FALSE;
-		}
-		else{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_channelClient connect success!");
+			if (blogevt) {
+				LogWarn(Severity_Middle, Error_InvalidState, LOG_EVT_CONNEC_ASSISTCHAN_FAILED,
+					CSimpleStringA::Format("Connect to assistchan entity failed:0x%08x.", errorCode));
+			}
+			return Error_InvalidState;
 		}
-
-		if(Error == Error_Succeed)
-		{
+		else {
+			if (blogevt) {
+				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Connect to assistchan Client Succeed!");
+			}
+		
 			ChannelService_BeginState_Sub ChannelSub;
-			Error = m_pClient->BeginState(ChannelSub);
-			if (Error != Error_Succeed) 
+			errorCode = m_pClient->BeginState(ChannelSub);
+			if (Error_Succeed != errorCode)
 			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel failed!");
 				m_pClient->GetFunction()->CloseSession();
 				m_pClient = NULL;
-				return FALSE;
+				return errorCode;
 			}
-			else{
+			else {
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel success!");
 			}
-		}
-
-		if(Error == Error_Succeed)
-		{
+			
 			ChannelService_BeginRecv_Sub Sub;
 			Sub.type = ACM_TYPE_FLW;
-			Error = m_pClient->BeginRecv(Sub);
-			if (Error != Error_Succeed) 
+			errorCode = m_pClient->BeginRecv(Sub);
+			if (Error_Succeed != errorCode)
 			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Register ACM_TYPE_FLW failed!");
 				m_pClient->GetFunction()->CloseSession();
 				m_pClient = NULL;
-				return FALSE;
+				return errorCode;
 			}
-			else{
+			else {
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Register ACM_TYPE_FLW success!");
 			}
 		}
 	}
 
-	return TRUE;
+	return Error_Succeed;
 }
 
+bool CFlowControlFSM::IsAssistchanConnectSessionOK()
+{
+	return (m_pClient != NULL && !m_pClient->QuerySessionClosed());
+}
+
+void CFlowControlFSM::FreeAssistchanClient()
+{
+	if (m_pClient) {
+		m_pClient->GetFunction()->CloseSession();
+		m_pClient = NULL;
+	}
+}
+
+
 unsigned int CFlowControlFSM::s0_on_event(FSMEvent* event)
 {
 	if (event->iEvt == USER_EVT_ANSACMFLOW) {
 		AgentFlowResult evt;
 		evt.error = Error_NetBroken;
 		SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(AgentFlowResult), SP_MSG_SIG_OF(AgentFlowResult), evt);
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S0_ANSACMFLOW, "s0 receive ANSACMFLOW");
 	} else if (event->iEvt == USER_EVT_REQAGENTFLOW) {
 		AgentFlowResult evt;
 		evt.error = Error_NetBroken;
 		SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(AgentFlowResult), SP_MSG_SIG_OF(AgentFlowResult), evt);
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S0_REQAGENTFLOW, "s0 receive REQAGENTFLOW");
 	}
 	else if (event->iEvt == USER_EVT_ASSIS_IDEL)
 	{
-		ReConnectionAssistchan();
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
+
 unsigned int CFlowControlFSM::s1_on_event(FSMEvent* event)
 {
 	if (event->iEvt == USER_EVT_REQAGENTFLOW) {
@@ -199,12 +272,14 @@ unsigned int CFlowControlFSM::s1_on_event(FSMEvent* event)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(reqContext).GetData());
 			Info.data = buf.ToBlob();
 			Error = m_pClient->Send(Info);
-		} else 
-		{
+		} 
+		else {
 			Error = Error_NetBroken;
+			LogWarn(Severity_Low, Error_Debug, LOG_ERR_S1_REQAGENTFLOW_FAILED, "s1 receive REQAGENTFLOW but chan is off.");
 		}
 		return Error == Error_Succeed ? 1 : 0;
-	} else if (event->iEvt == USER_EVT_NTFENTFLOW) {
+	} 
+	else if (event->iEvt == USER_EVT_NTFENTFLOW) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("spbroadcast NotifyEnterFlowEvent");
 		NotifyEnterFlowEvent *nef = static_cast<NotifyEnterFlowEvent*>(event);
 		NotifyEnterFlow evt;
@@ -212,7 +287,10 @@ unsigned int CFlowControlFSM::s1_on_event(FSMEvent* event)
 	}
 	else if (event->iEvt == USER_EVT_ASSIS_IDEL)
 	{
-		ReConnectionAssistchan();
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S1_ASSIS_IDEL, "s1 ASSIS_IDEL.");
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
@@ -240,11 +318,16 @@ unsigned int CFlowControlFSM::s2_on_event(FSMEvent* event)
 		SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(ACMFlowInvoke), SP_MSG_SIG_OF(ACMFlowInvoke), evt);
 	} else if (event->iEvt == USER_EVT_NTFENTFLOW) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("notify enter flow, disallow control!");
-		DisallowControl();
+		ErrorCodeEnum result = DisallowControl();
+		if (result != Error_Succeed){
+			LogWarn(Severity_Low, Error_Debug, LOG_ERR_S2_NTFENTFLOW_FAILED, "s2 send NTFENTFLOW error.");
+		}
 	}
-	else if (event->iEvt == USER_EVT_ASSIS_IDEL)
-	{
-		ReConnectionAssistchan();
+	else if (event->iEvt == USER_EVT_ASSIS_IDEL){
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S2_ASSIS_IDEL, "s2 ASSIS_IDEL.");
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
@@ -282,6 +365,7 @@ unsigned int CFlowControlFSM::s3_on_event(FSMEvent* event)
 			Error = m_pClient->Send(Info);
 		} else {
 			Error = Error_NetBroken;
+			LogWarn(Severity_Low, Error_Debug, LOG_ERR_S3_ANSACMFLOW_FAILED, "s3 send ANSACMFLOW error.");
 		}
 		return Error == Error_Succeed ? 1 : 0;
 	} else if (event->iEvt == USER_EVT_CHAN_OFF) {
@@ -291,7 +375,10 @@ unsigned int CFlowControlFSM::s3_on_event(FSMEvent* event)
 	}
 	else if (event->iEvt == USER_EVT_ASSIS_IDEL)
 	{
-		ReConnectionAssistchan();
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S3_ASSIS_IDEL, "s3 ASSIS_IDEL.");
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
@@ -299,13 +386,19 @@ void CFlowControlFSM::s5_on_entry()
 {
 	
 }
+
 void CFlowControlFSM::s5_on_exit() { }
+
 unsigned int CFlowControlFSM::s5_on_event(FSMEvent* event)
 {
 	if (event->iEvt == USER_EVT_DISCTRL) {
-		DisallowControl();
-	} else if (event->iEvt == USER_EVT_REQAGENTFLOW) {
-		ReqAgentFlowEvent *rafe = static_cast<ReqAgentFlowEvent*>(event);
+		ErrorCodeEnum result = DisallowControl();
+		if (result != Error_Succeed) {
+			LogWarn(Severity_Low, Error_Debug, LOG_ERR_S5_DISCTRL_FAILED, "s5 send DISCTRL error.");
+		}
+	}
+	else if (event->iEvt == USER_EVT_REQAGENTFLOW) {
+		ReqAgentFlowEvent* rafe = static_cast<ReqAgentFlowEvent*>(event);
 		ErrorCodeEnum Error;
 		if (m_pClient) {
 			ChannelService_Send_Info Info;
@@ -320,22 +413,34 @@ unsigned int CFlowControlFSM::s5_on_event(FSMEvent* event)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(reqContext).GetData());
 			Info.data = buf.ToBlob();
 			Error = m_pClient->Send(Info);
-		} else {
+		}
+		else {
 			Error = Error_NetBroken;
+			LogWarn(Severity_Low, Error_Debug, LOG_ERR_S5_REQAGENTFLOW_FAILED, "s5 send REQAGENTFLOW error.");
 		}
 		return Error == Error_Succeed ? 1 : 0;
 	}
 	else if (event->iEvt == USER_EVT_ASSIS_IDEL)
 	{
-		ReConnectionAssistchan();
+		LogWarn(Severity_Low, Error_Debug, LOG_ERR_S5_ASSIS_IDEL, "s5 ASSIS_IDEL.");
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
 
+void CFlowControlFSM::s7_on_entry()
+{
+	LogWarn(Severity_Low, Error_Debug, LOG_ERR_S7_ENTRY, "s7 ENTRY.");
+}
+
 unsigned int CFlowControlFSM::s7_on_event(FSMEvent* event)
 {
 	if (event->iEvt == USER_EVT_ASSIS_IDEL){
-		ReConnectionAssistchan();
+		if (Error_Succeed == ConnectToAssistchan(false)) {
+			m_bConnectAssit = true;
+		}
 	}
 	return 0;
 }
@@ -365,7 +470,7 @@ void CFlowControlFSM::ProcessPacket( int sub_type, CBlob &blob )
 		buf & e->context;
 		PostEventFIFO(e);
 	} else {
-		LOG_TRACE("unknown sub_type from agent!");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown sub_type from agent!");
 	}
 }
 

+ 9 - 3
Module/mod_initiativetransfer/FlowControlFSM.h

@@ -154,19 +154,25 @@ public:
 	unsigned int s5_on_event(FSMEvent* event);
 	void s6_on_entry() {}
 	void s6_on_exit() {}
-	unsigned int s6_on_event(FSMEvent* event);
-	void s7_on_entry() {}
+	unsigned int s6_on_event(FSMEvent* event) {};
+	void s7_on_entry();
 	void s7_on_exit() {}
 	unsigned int s7_on_event(FSMEvent* event);
 
 	void ProcessPacket(int sub_type, CBlob &blob);
 
 	ErrorCodeEnum SetState(const char *s, const char *sdesc);
-	BOOL  ReConnectionAssistchan();
+	
+	//BOOL  ReConnectionAssistchan();
+	bool  IsAssistchanEntityAvailable();
+	ErrorCodeEnum ConnectToAssistchan(bool blogevt = true);
+	bool IsAssistchanConnectSessionOK();
+	void FreeAssistchanClient();
 
 	ErrorCodeEnum DisallowControl();
 
 	BOOL m_bIspad;
+	bool m_bConnectAssit;
 private:
 	BOOL m_bChanOff;
 	ChannelClient *m_pClient;

+ 31 - 6
Module/mod_initiativetransfer/mod_initiativetransfer.cpp

@@ -8,7 +8,11 @@
 
 using namespace InitiativeTransfer;
 
-#define LOG_EVT_ENTER_ACM_FLOW	 0x30500001          //进入坐席控制流程
+#ifndef RVC_CONNECT_ASSIST_ID 
+#define RVC_CONNECT_ASSIST_ID 1
+#endif
+
+#define LOG_EVT_ENTER_ACM_FLOW	 0x30500001				//进入坐席控制流程
 
 #define LOG_EVT_UI_RETURNMENU		0x30B00006				//退出到主菜单
 
@@ -29,10 +33,10 @@ private:
 	CFlowControlEntity *m_pEntity;
 };
 
-class CFlowControlEntity : public CEntityBase, public ILogListener
+class CFlowControlEntity : public CEntityBase, public ILogListener, public ITimerListener
 {
 public:
-	CFlowControlEntity() {}
+	CFlowControlEntity() { }
 	virtual ~CFlowControlEntity() {}
 	virtual const char *GetEntityName() const { return "InitiativeTransfer"; }
 	virtual bool IsService()const{return true;}
@@ -43,6 +47,7 @@ public:
 		m_bIsPadType = FALSE;
 		m_fsm = new CFlowControlFSM();
 		ErrorCodeEnum Error = m_fsm->Init(this);
+
 		int i = 0;
 		CSmartPointer<IEntityFunction> spFunction = GetFunction();
 		m_arrListener.Init(2);
@@ -67,11 +72,13 @@ public:
 
 	void OnStarted()
 	{
-		if (m_fsm->ReConnectionAssistchan()){
+		if (Error_Succeed == m_fsm->ConnectToAssistchan(false)){
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnStarted ConnectionAssistchan success!");
+			m_fsm->m_bConnectAssit = true;
 		}
 		else{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnStarted ConnectionAssistchan failed!");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnStarted ConnectionAssistchan failed, SetTimer.");
+			GetFunction()->SetTimer(RVC_CONNECT_ASSIST_ID, this, 5000);
 		}
 	}
 
@@ -87,7 +94,9 @@ public:
 		}
 		m_arrListener.Clear();
 	}
+
 	CSmartPointer<ITransactionContext> m_pTransactionContext;
+	
 	void FinishClose(ErrorCodeEnum Error)
 	{
 		if (m_pTransactionContext != NULL) 
@@ -103,6 +112,8 @@ public:
 		if (dwUserCode == LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS)
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS");
+			GetFunction()->SetTimer(RVC_CONNECT_ASSIST_ID, this, 5000);
+			m_fsm->m_bConnectAssit = false;
 			Sleep(1000);
 			m_fsm->PostEventFIFO(new FSMEvent(USER_EVT_ASSIS_IDEL));
 		}
@@ -115,10 +126,24 @@ public:
 
 	virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszClass*/)
 	{
-		LOG_FUNCTION();
 		return new FlowControlServiceSession(this);
 	}
 
+	virtual void OnTimeout(DWORD dwTimerID)
+	{
+		if (RVC_CONNECT_ASSIST_ID == dwTimerID) {
+			if (false == m_fsm->m_bConnectAssit) {
+				if (Error_Succeed == m_fsm->ConnectToAssistchan(false)) {
+					m_fsm->m_bConnectAssit = true;
+				}
+			}
+
+			if (m_fsm->m_bConnectAssit) {
+				GetFunction()->KillTimer(RVC_CONNECT_ASSIST_ID);
+			}
+		}
+	}
+
 	void SwitchToAgentFlow(CSimpleStringW req_context)
 	{
 		CSimpleStringA str_req = CSimpleStringW2A(req_context);

+ 4 - 0
Module/mod_interactioncontext/mod_interactioncontext.cpp

@@ -94,6 +94,10 @@ public:
 		if (Error_Succeed == ConnectAssistChannel()) {
 			m_bConnectAssist = TRUE;
 		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+			GetFunction()->SetTimer(1, this, 3270);
+		}
 	}
 
 

+ 5 - 2
Module/mod_interactivecontrol/mod_interactivecontrol.cpp

@@ -73,6 +73,10 @@ void CITCtrlEntity::OnStarted()
 	if (Error_Succeed == ConnectAssistChannel()) {
 		m_bConnectAssist = TRUE;
 	}
+	else {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+		GetFunction()->SetTimer(1, this, 3370);
+	}
 
 	if (Error_Succeed == ConnectToLocalPlayer(false)) {
 		m_bConnectPlayer = TRUE;
@@ -1061,7 +1065,7 @@ void CITCtrlEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,co
 				m_bConnectAssist = TRUE;
 			}
 			else {
-				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
 				GetFunction()->SetTimer(1, this, 3370);
 			}
 		}
@@ -1866,7 +1870,6 @@ void CITCtrlEntity::FreeRecordClient()
 {
 	if (m_pRecordClient) {
 		m_pRecordClient->GetFunction()->CloseSession();
-		m_pRecordClient->SafeDelete();
 		m_pRecordClient = NULL;
 	}
 }

+ 4 - 0
Module/mod_screenshot/mod_screenshot.cpp

@@ -189,6 +189,10 @@ public:
 		if (Error_Succeed == ConnectAssistChannel()) {
 			m_bConnectAssist = TRUE;
 		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+			GetFunction()->SetTimer(1, this, 3370);
+		}
 	}
 
 	ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)

+ 4 - 0
Module/mod_sipphone/mod_sipphone.cpp

@@ -559,6 +559,10 @@ void CSIPEntity::OnStarted()
 	if (Error_Succeed == ConnectAssistChannel()){
 		m_bConnectedAssist = TRUE;
 	}
+	else {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+		GetFunction()->SetTimer(2, this, 3200);
+	}
 
 	LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sip phone started successfully.");
 }

+ 4 - 0
Module/mod_snapshot/mod_snapshot.cpp

@@ -127,6 +127,10 @@ public:
 		if (Error_Succeed == ConnectAssistChannel()) {
 			m_bConnectAssist = TRUE;
 		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start timer for reconnect to assist channel.");
+			GetFunction()->SetTimer(2, this, 3370);
+		}
 	}
 
 	ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)