< Previous by Date Date Index Next by Date >
  Thread Index  

Re: [reSIProcate-users] FW: customizing SIP message


When you call getMessageRequest you should assign it to a reference and not copy it, ie:
SipMessage& msg = cpmh.get()->getMessageRequest();

Scott

On Thu, Dec 8, 2011 at 4:42 AM, he yaxin <crazyplayer1983@xxxxxxxxxxxx> wrote:
Hi Philip/Scott, the following is the post I sent on 30th, Nov.
 
Thanks!
 
Regards,
Alex

----- 转发的邮件 -----
发件人: he yaxin <crazyplayer1983@xxxxxxxxxxxx>
收件人: "resiprocate-users@xxxxxxxxxxxxxxx" <resiprocate-users@xxxxxxxxxxxxxxx>
发送日期: 2011年12月7日, 星期三, 下午 3:18
主题: customizing SIP message

Hi All,
I am trying to customize the MESSAGE(pager) IM sip message by adding an extension header into the message.
It looks like the routine to send a SIMPLE IM here is as follows:
string to = “sip:user@xxxxxxxxxxxxxxx”;
ClientPagerMessageHandle cpmh = mDum.makePagerMessage(NameAddr(to));
cpmh.get()->page(“a message to be sent”);
However, I am looking to add an extra header in the message for the usage of my own application.(PS. Will this extra header and its value be copied into the corresponding response of the message? This extra header is important because it will be used to match the request from the non-SIP domain and the response from the SIP domain) I noticed that there is a “getMessageRequest()”function in the class ClientpagerMessage that allows the user to “adorn the MESSAGE message if desired” and it returns the actual reference of the request SIP message, so I gave it a go with the following code:
static const resip::ExtensionHeader h_CustomizedHeader("CustomizedHeader");
SipMessage msg = cpmh.get()->getMessageRequest();
msg.header(h_CustomizedHeader).push_back(StringCategory("1122334455"));
cpmh.get()->page(“a message to be sent”);
The MESSAGE message got sent out, but I didn’t see the “h_CustomizedHeader”header in the SIP message when I have captured it in Wireshark.
I am confused because the “getMessageRequest()” function returns the reference of the request SIP message and I see the “pager()/pageFirstMsgQueued()”is sending out the same request SIP message. Could anybody shed some light on why the extension header was not added into the message that got sent and how I can add an extension header correctly into the MESSAGE sip message? Thanks a million!
Regards,
Alex