0

我收到了这样的消息:

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 ======================\n\n\n" << 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);

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

4

1 回答 1

1

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

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

于 2020-04-02T08:35:32.377 回答