|
|
@@ -23,17 +23,19 @@ void ChannelClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-CFlowControlFSM::CFlowControlFSM(): m_bIspad(FALSE)
|
|
|
+CFlowControlFSM::CFlowControlFSM(): m_bIspad(FALSE), m_pClient(NULL)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
CFlowControlFSM::~CFlowControlFSM()
|
|
|
{
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void CFlowControlFSM::OnStateTrans( int iSrcState, int iDstState )
|
|
|
{
|
|
|
- LOG_TRACE("Trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
|
|
|
switch (iDstState) {
|
|
|
case s0:
|
|
|
SetState("O", "Offline"); // offline
|
|
|
@@ -57,31 +59,33 @@ 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 = NULL;
|
|
|
- }
|
|
|
- } else {
|
|
|
- m_pClient->SafeDelete();
|
|
|
- m_pClient = NULL;
|
|
|
- }
|
|
|
+ //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) {
|
|
|
+ //if (Error == Error_Succeed)
|
|
|
+ //{
|
|
|
AddStateHooker(this);
|
|
|
- }
|
|
|
+ //}
|
|
|
|
|
|
- return Error;
|
|
|
+ return Error_Succeed;
|
|
|
}
|
|
|
ErrorCodeEnum CFlowControlFSM::OnExit()
|
|
|
{
|
|
|
@@ -105,21 +109,23 @@ BOOL CFlowControlFSM::ReConnectionAssistchan()
|
|
|
{
|
|
|
m_pClient->GetFunction()->CloseSession();
|
|
|
m_pClient = NULL;
|
|
|
- Dbg("Close AssistChannel Session ");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Close AssistChannel Session ");
|
|
|
}
|
|
|
|
|
|
if (m_pClient == NULL)
|
|
|
{
|
|
|
- Dbg("ReConnection AssistChannel Session");
|
|
|
ErrorCodeEnum Error;
|
|
|
m_pClient = new ChannelClient(m_pEntity, this);
|
|
|
Error = m_pClient->Connect();
|
|
|
if (Error != Error_Succeed)
|
|
|
{
|
|
|
- m_pClient->SafeDelete();
|
|
|
- Dbg("m_channelClient connect fail!");
|
|
|
+ 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)
|
|
|
{
|
|
|
@@ -127,11 +133,14 @@ BOOL CFlowControlFSM::ReConnectionAssistchan()
|
|
|
Error = m_pClient->BeginState(ChannelSub);
|
|
|
if (Error != Error_Succeed)
|
|
|
{
|
|
|
- LOG_TRACE("BeginState biz channel failed!");
|
|
|
+ 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)
|
|
|
@@ -141,11 +150,14 @@ BOOL CFlowControlFSM::ReConnectionAssistchan()
|
|
|
Error = m_pClient->BeginRecv(Sub);
|
|
|
if (Error != Error_Succeed)
|
|
|
{
|
|
|
- LOG_TRACE("BeginState biz channel failed!");
|
|
|
+ LOG_TRACE("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!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -184,7 +196,7 @@ unsigned int CFlowControlFSM::s1_on_event(FSMEvent* event)
|
|
|
buf.OpenWrite();
|
|
|
CSimpleString16Bit reqContext = CSimpleStringW216Bit(rafe->req_context);
|
|
|
buf & reqContext;
|
|
|
- Dbg("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(reqContext).GetData());
|
|
|
+ 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
|
|
|
@@ -193,7 +205,7 @@ unsigned int CFlowControlFSM::s1_on_event(FSMEvent* event)
|
|
|
}
|
|
|
return Error == Error_Succeed ? 1 : 0;
|
|
|
} else if (event->iEvt == USER_EVT_NTFENTFLOW) {
|
|
|
- LOG_TRACE("spbroadcast NotifyEnterFlowEvent");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("spbroadcast NotifyEnterFlowEvent");
|
|
|
NotifyEnterFlowEvent *nef = static_cast<NotifyEnterFlowEvent*>(event);
|
|
|
NotifyEnterFlow evt;
|
|
|
SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(NotifyEnterFlow), SP_MSG_SIG_OF(NotifyEnterFlow), evt);
|
|
|
@@ -218,7 +230,7 @@ unsigned int CFlowControlFSM::s2_on_event(FSMEvent* event)
|
|
|
CSimpleStringW ans_context = CSimpleString16Bit2W(afe->ans_context);
|
|
|
evt.ans_context = ans_context;
|
|
|
evt.error = afe->err ? Error_Unexpect : Error_Succeed;
|
|
|
- Dbg("AgentFlowResult!!!!!");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("AgentFlowResult!!!!!");
|
|
|
SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(AgentFlowResult), SP_MSG_SIG_OF(AgentFlowResult), evt);
|
|
|
} else if (event->iEvt == USER_EVT_REQACMFLOW) {
|
|
|
ReqACMFlowEvent *afe = static_cast<ReqACMFlowEvent *>(event);
|
|
|
@@ -227,7 +239,7 @@ unsigned int CFlowControlFSM::s2_on_event(FSMEvent* event)
|
|
|
evt.req_context = req_context;
|
|
|
SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(ACMFlowInvoke), SP_MSG_SIG_OF(ACMFlowInvoke), evt);
|
|
|
} else if (event->iEvt == USER_EVT_NTFENTFLOW) {
|
|
|
- LOG_TRACE("notify enter flow, disallow control!");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("notify enter flow, disallow control!");
|
|
|
DisallowControl();
|
|
|
}
|
|
|
else if (event->iEvt == USER_EVT_ASSIS_IDEL)
|
|
|
@@ -265,7 +277,7 @@ unsigned int CFlowControlFSM::s3_on_event(FSMEvent* event)
|
|
|
buf.OpenWrite();
|
|
|
CSimpleString16Bit ansContext = CSimpleStringW216Bit(afe->ans_context);
|
|
|
buf& ansContext;
|
|
|
- Dbg("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(ansContext).GetData());
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(ansContext).GetData());
|
|
|
Info.data = buf.ToBlob();
|
|
|
Error = m_pClient->Send(Info);
|
|
|
} else {
|
|
|
@@ -305,7 +317,7 @@ unsigned int CFlowControlFSM::s5_on_event(FSMEvent* event)
|
|
|
buf.OpenWrite();
|
|
|
CSimpleString16Bit reqContext = CSimpleStringW216Bit(rafe->req_context);
|
|
|
buf& reqContext;
|
|
|
- Dbg("%s After convert: %s", __FUNCTION__, CSimpleString16Bit2A(reqContext).GetData());
|
|
|
+ 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 {
|
|
|
@@ -322,9 +334,8 @@ unsigned int CFlowControlFSM::s5_on_event(FSMEvent* event)
|
|
|
|
|
|
unsigned int CFlowControlFSM::s7_on_event(FSMEvent* event)
|
|
|
{
|
|
|
- if (event->iEvt == USER_EVT_ASSIS_IDEL)
|
|
|
- {
|
|
|
- ReConnectionAssistchan();
|
|
|
+ if (event->iEvt == USER_EVT_ASSIS_IDEL){
|
|
|
+ ReConnectionAssistchan();
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -360,7 +371,7 @@ void CFlowControlFSM::ProcessPacket( int sub_type, CBlob &blob )
|
|
|
|
|
|
ErrorCodeEnum CFlowControlFSM::SetState(const char *s, const char *sdesc)
|
|
|
{
|
|
|
- LOG_TRACE("set BackInitiative to %s, %s", s, sdesc);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set BackInitiative to %s, %s", s, sdesc);
|
|
|
return m_pEntity->GetFunction()->SetSysVar("BackInitiative", s);
|
|
|
}
|
|
|
|
|
|
@@ -380,9 +391,6 @@ ErrorCodeEnum CFlowControlFSM::DisallowControl()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
void NotifyEnterFlowEvent::OnUnhandled()
|
|
|
{
|
|
|
LOG_FUNCTION();
|