如何处理pjsip消息



我收到了这样的消息:

07:27:06.671           pjsua_core.c  .RX 544 bytes Request msg MESSAGE/cseq=20 (rdata0x7ff3a00086b8) from UDP 192.168.42.128:5060:
MESSAGE sip:34020000002000000001@3402000000 SIP/2.0
Via: SIP/2.0/UDP 192.168.42.128:5060;rport;branch=z9hG4bK40553892
From: <sip:34020000001320000001@3402000000>;tag=365877371
To: <sip:34020000002000000001@3402000000>
Call-ID: 300721342
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: IP Camera
Content-Length:   179
<?xml version="1.0" encoding="GB2312"?>
<Notify>
<CmdType>Keepalive</CmdType>
<SN>2608</SN>
<DeviceID>34020000001320000001</DeviceID>
<Status>OK</Status>
<Info>
</Info>
</Notify>

我用on_rx_request()听,然后打印一些东西。

static pj_bool_t default_mod_on_rx_request(pjsip_rx_data *rdata) {
cout << "=================== rx request ======================nnn" << endl;
pjsip_endpt_create_response(pjsua_get_pjsip_endpt(), rdata, 200, NULL, &tdata);
pjsip_endpt_send_response2(pjsua_get_pjsip_endpt(), rdata, tdata, NULL, NULL);
return PJ_TRUE;
}

使用pjsip_module并注册它,REGISTERreq就可以了!

pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), &mod_default_handler);

当运行时,没有东西输出,那么我应该如何处理数据。感谢

我知道,MESSAGE应该用pjsua2中Account的onInstantMessage()方法处理。例如:

void ServerAccount::onInstantMessage(OnInstantMessageParam &prm)
{
std::cout << "prm.fromUri: " + prm.fromUri << std::endl;
std::cout << "prm.toUri: " + prm.toUri << std::endl;
std::cout << "prm.contactUri: " + prm.contactUri << std::endl;
std::cout << "prm.contentType: " + prm.contentType << std::endl;
std::cout << "---------" << std::endl;
std::cout << prm.msgBody << std::endl;
}

参数文档:OnInstantMessageParam

相关内容

  • 没有找到相关文章

最新更新