⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmppapi_test.cpp

📁 移动短信api
💻 CPP
字号:
// cmppapi_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

//包含需要的文件.
#include "md5.h"
#include "cmpp.h"

#pragma comment(lib, "cmppapi.lib")

#define CMPP_IMPORT

//用一全局变量记录SubmitResp中的MsgId,用于测试Cancel命令.
_int64 g_nMsgid = 0;
 
void OnSmgMsg(CMPP_SMGTOSP css)
{
	printf("这是消息处理函数打印出来的:**smg msg,len = %d, cmd = 0x%08x, seq = %d**\n", \
		css.pk_head.nTotalLength, css.pk_head.nCommandId, css.pk_head.nSeqId);

	if (css.pk_head.nCommandId == 0x80000004) {
		g_nMsgid = css.pk_body.pk_submitresp.nMsgid;
	}
	return;
}

void OutProgramInfo()
{
	printf("\n*****************************************************************************\n");
	printf("**软件名称 - <<中国移动通信CMPP3.0短消息网关开发接口库>> V1.0 客户端例程.\n");
	printf("**作者主页 - http://princetoad.xiloo.com\n");
	printf("**联系方式 - Email:princetoad@126.com\n");
	printf("**授权方式 - Used Free,SourceCode On Sale.\n");
	printf("**********************Published By PrinceToad Nov.22.03.*********************\n\n");
}

int main(int argc, char* argv[])
{
	int nRetCode = 0;

	OutProgramInfo();

	CCmppClient cmpp;

	printf("Press Any To Start CmppClient.\n");
	system("pause");
	//1.启动CMPPCLIENT模块.
	nRetCode = cmpp.Start("127.0.0.1", 7890, "902100", "jxjd185", 0x30, OnSmgMsg);
	
	if (0 != nRetCode) {
		printf("CmppClient Start Failed With Error: %d.\n", nRetCode);
		system("pause");
		return nRetCode;
	}
	else {
		printf("CmppClient Module Start Success,Press Any To Test Submit Command.\n");
		system("pause");
	}
	
	//2.测试SUBMIT命令.
	nRetCode = cmpp.Submit(0, 1, 1, \
		0, 3, "1234", \
		0, "13691114875", 0, \
		0, 0, 0, \
		"13911638107", "123", "456", NULL, NULL, \
		"666", 1, "13301088888", 0, \
		4, "test", "999");
	
	printf("Submit result : %d\n", nRetCode);

	printf("Press Any To Test Query Command.\n");
	system("pause");

	//3.测试QUERY命令.
	nRetCode = cmpp.Query("20031120", 0);		//查询总量.
	printf("Query result : %d\n", nRetCode);

	printf("Press Any To Test Cancel Command.\n");
	system("pause");
	//4.测试CANCEL命令.
	nRetCode = cmpp.Cancel(g_nMsgid);
	printf("Cancel result : %d\n", nRetCode);

	printf("Press Any To Test ActiveTest Command.\n");
	system("pause");
	//5.测试ACTIVETEST命令.
	nRetCode = cmpp.ActiveTest();
	printf("ActiveTest result : %d\n", nRetCode);

	printf("Press Any To Test Terminate Command And Release CmppClient Module.\n");
	system("pause");
	//6.测试TERMINATE命令.
	cmpp.Release();

	printf("Press Any To Exit This Test Program.\n");
	system("pause");

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -