📄 msg_center.h
字号:
#ifndef _MSG_CENTER_H
#define _MSG_CENTER_H
#include "entity_pt.h"
#include "entity_cmpplink.h"
#include "TServerLink_Entity.h"
#include "afxmt.h"
DWORD WINAPI PeekMsgThread(LPVOID lpParam);
extern TServerLink_Entity* g_pSgipEntity;
class TMSG_CENTER
{
public:
TMSG_CENTER(){};
~TMSG_CENTER()
{
SgipServerEntity->Uninit();
Sleep(500);
delete SgipServerEntity;
SgipServerEntity = NULL;
TerminateThread(m_MainHandle,0);
CloseHandle(m_MainHandle);
};
BOOL Init()
{
SgipServerEntity = new TServerLink_Entity();
g_pSgipEntity = SgipServerEntity;
if( !ReadInitFile()||
(!CmppEntity.Init(gStructTransInfo.szTransIP,gStructTransInfo.nPort))||
(!PtEntity.Init(gStructClientInfo.szIP,gStructClientInfo.nPort))||
(!SgipServerEntity->Init(gStructRecvInfo.szIP,gStructRecvInfo.nPort)))
return false;
//创建处理线程
DWORD dwThreadId;
m_MainHandle = CreateThread(NULL, 0, PeekMsgThread, this, 0, &dwThreadId);
if(m_MainHandle == NULL)
return false;
return true;
};
public:
HANDLE m_MainHandle;
//三个实体
TPt_Entity PtEntity;
TCmppLink_Entity CmppEntity;
TServerLink_Entity* SgipServerEntity;
//关键区变量
CCriticalSection CSSgipDelivery;
CCriticalSection CSSgipReport;
public:
void SGIP_Report(char buf[],int nMsgLen);
void SGIP_Deliver(char buf[],int nMsgLen);
void Pt_MsgProc(char *buf);
void CmppLink_MsgProc(char *buf);
void SgipServer_MsgProc(char *buf);
char getHex(char c);
void byteToStr(char sourcebuf[], BYTE Msg_Length, char *Destbuf);
private:
//处理平台提交的消息
BOOL PT_Submit(char buf[],UINT nbufLen);
BOOL PT_Query(char buf[],UINT nbufLen);
//处理标准SMPP 协议
//短信提交的应答消息
BOOL CMPP12_SubmitRep(void* buf,UINT nBufLen);
//短信下发消息
BOOL CMPP12_Deliver(void* buf,UINT nBufLen);
//短信查询应答消息
BOOL CMPP12_QueryRep(void* buf,UINT nBufLen);
private:
//把SMPP数据结构组成SMPP数据包
UINT MakeCMPP12Buf(char* OutBuf,void* InputStruct,UINT nCommandId);
//通过消息包,获取消息内容
void GetCMPP12DataFromBuf(void* ReceiveBuf,char* buf,UINT nCommandID);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -