📄 receivesmthread.cpp
字号:
// ReceiveSMThread.cpp : implementation file
//
#include "stdafx.h"
#include "sendsm.h"
#include "ReceiveSMThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CSendSMApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CReceiveSMThread
IMPLEMENT_DYNCREATE(CReceiveSMThread, CWinThread)
CReceiveSMThread::CReceiveSMThread()
{
}
CReceiveSMThread::~CReceiveSMThread()
{
}
BOOL CReceiveSMThread::InitInstance()
{
// TODO: perform and per-thread initialization here
return TRUE;
}
int CReceiveSMThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CReceiveSMThread, CWinThread)
//{{AFX_MSG_MAP(CReceiveSMThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReceiveSMThread message handlers
int CReceiveSMThread::Run()
{
dpl_status_t stat;
cmppe_packet cp;
cmppe_cancel cc;
CString m_Msg1;
START:
Sleep(500);
memset(&cp,0,sizeof(cmppe_packet));
memset(&cc,0,sizeof(cmppe_cancel));
//退出线程
if ( theApp.m_bExitFlag )
{
ExitThread( 0 );
return 0;
}
while(1)
{
if ( theApp.m_bExitFlag )
{
ExitThread( 0 );
return 0;
}
stat = cmpp_recv(&theApp.conn,&cp,1);
if (stat == DPL_SUCCESS)
{
switch( cp.pk_head.pk_cmd )
{
case CMPPE_NACK_RESP:
break;
case CMPPE_LOGIN_RESP:
break;
case CMPPE_LOGOUT_RESP:
break;
case CMPPE_ROUTE_RESP:
break;
case CMPPE_SUBMIT_RESP:
{
if (cp.pk_head.pk_stat == 0)
{
m_Msg1.Format("[Msg_id = %0s]--->[stat = %02x]",cp.pk_data.pk_submit_resp.msg_id,cp.pk_head.pk_stat);
theApp.AddToList(m_Msg1);
}
break;
}
case CMPPE_DELIVER:
{
if(cp.pk_data.pk_deliver.status_rpt == 1)
{
m_Msg1.Format("\t[msg_id = %s]\t[stat = %03d]\t[stime = %s]\t[dtime = %s]",\
cp.pk_data.pk_deliver.pk_sm.sm_rpt.msg_id,cp.pk_data.pk_deliver.pk_sm.sm_rpt.final_status,\
cp.pk_data.pk_deliver.pk_sm.sm_rpt.submit_date,cp.pk_data.pk_deliver.pk_sm.sm_rpt.final_date);
theApp.AddToList(m_Msg1);
}else
{
m_Msg1.Format("\t[short_msg == %s]\n",cp.pk_data.pk_deliver.pk_sm.short_msg);
theApp.AddToList(m_Msg1);
}
stat = cmpp_deliver_resp(&theApp.conn,cp.pk_head.pk_seq,cp.result);
if(stat != DPL_SUCCESS)
{
theApp.Logout();
Sleep(1000);
theApp.Login();
goto START;
}
break;
}
case CMPPE_ACTIVE_RESP:
{
if (DPL_SUCCESS != cmpp_active_test( &theApp.conn))
{
m_Msg1.Format("无法激活连接");
}
else
{
m_Msg1.Format("已被激活连接");
}
//theApp.AddToList(m_Msg1);
//Sleep(15000);
break;
}
case CMPPE_ACTIVE:
{
if (DPL_SUCCESS != cmpp_active_test( &theApp.conn))
{
m_Msg1.Format("网关无法激活连接");
}
else
{
m_Msg1.Format("网关已被激活连接");
}
//theApp.AddToList(m_Msg1);
//Sleep(15000);
break;
}
default:
{
m_Msg1.Format("接收到其他消息%X",cp.pk_head.pk_cmd);
theApp.AddToList(m_Msg1);
theApp.Logout();
Sleep(10000);
theApp.Login();
break;
}
}
}
else
{
// if( DPL_SUCCESS != cmpp_active_test( &theApp.conn))
{
theApp.Logout();
Sleep(10000);
theApp.Login();
goto START;
}
}
Sleep(5000);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -