TA的每日心情 | 开心 2015-5-3 23:41 |
---|
签到天数: 2 天 连续签到: 1 天 [LV.1]测试小兵
|
//transform
#include "login.h"
#define TRANS_SUCCESS 0
#define TRANS_FAIL -1
int SendRecvIM(char *pszSSocketName,char *pszRSocketName)
{
char errorMsg[200];
//启动事务
lr_start_transaction("TRANSFORM_IM_TRANS");
//发送方发送一条即时消息,接受方接收这个消息
lrs_send(pszSSocketName,"instantMsgSend",LrsLastArg);
lrs_receive(pszSSocketName,"instantMsgResRecv",LrsLastArg);
lrs_set_recv_timeout(5,0);
lrs_receive(pszRSocketName,"instantMsgRecv",LrsLastArg);
//检测接受方接收到的消息,如果存在关键字message,则转发消息事务成功,回复状态报告;否则,事务失败,打印错误信息
lrs_save_param(pszRSocketName,NULL,"recv_msg",1,7);
if(strcmp(lr_eval_string("{recv_msg}"),"message")==0)
{
lrs_send(pszRSocketName,"instantMsgSendReceipt",LrsLastArg);
lrs_receive(pszSSocketName,"instantMsgRevcReceipt",LrsLastArg);
lr_end_transaction("TRANSFORM_IM_TRANS",LR_PASS);
return TRANS_SUCCESS;
}
else
{
errorMsg[0]='\0';
lrs_save_param(pszRSocketName, NULL, "trans_fail", 0, 50);
strcat(errorMsg,lr_eval_string("{trans_fail}"));
lr_error_message(errorMsg);
lr_end_transaction("TRANSFORM_IM_TRANS", LR_FAIL);
return TRANS_FAIL;
}
}
/*构造转发消息的性能测试流程*/
int TransfromIM(char *pszSJID,char *pszRJID)
{
char *sSocketName;
char *rSocketName;
//设置变量
lr_save_string(pszSJID,"xmpp_sender_jid");
lr_save_string(pszRJID,"xmpp_recver_jid");
sSocketName = lr_eval_string("socket{xmpp_sender_jid}");
rSocketName = lr_eval_string("socket{xmpp_recver_jid}");
//消息发送方进行登录
Login(pszSJID,sSocketName);
//消息接收方进行登录
Login(pszRJID,rSocketName);
//循环执行消息的发送接收操作
while(1)
{
if(SendRecvIM(sSocketName,rSocketName) != TRANS_SUCCESS)
{
continue;
}
}
}
gloable:
//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
#include "lrs.h"
#include "transform_im.h"
//--------------------------------------------------------------------
// Global Variables |
|