sun.sun 发表于 2012-6-28 12:12:12

message-3

//transform
#include "login.h"
#define TRANS_SUCCESS 0
#define TRANS_FAIL   -1
int SendRecvIM(char *pszSSocketName,char *pszRSocketName)
{
char errorMsg;
//启动事务
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';
   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
页: [1]
查看完整版本: message-3