如何使用pjsua2 android发送带有自定义头的SIP消息

时间:2016-02-29 12:36:10

标签: android pjsip

参考enter link description here

我已成功发送消息,但我也想发送自定义标头,因为特定消息已发送给更新用户的获取状态

public void sendInstantMessage(String number, String msgBody) {
String sipServer = "aaa.ggg.net";
String buddy_uri = "<sip:" + number + "@" + sipServer + ">";

BuddyConfig bCfg = new BuddyConfig();
bCfg.setUri(buddy_uri);
bCfg.setSubscribe(false);

MyBuddy myBuddy = new MyBuddy(bCfg);
SendInstantMessageParam prm = new SendInstantMessageParam();
prm.setContent(msgBody);

// prm.setUserData(value)

try {
    myBuddy.create(account, bCfg);
    myBuddy.sendInstantMessage(prm);
    myBuddy.delete();
} catch (Exception e) {
    e.printStackTrace();
    return;
}

}

使用'Token pj :: SendInstantMessageParam :: userData作为链接enter link description here

我想发送userdata标头,但是如何发送该标头??

由于

1 个答案:

答案 0 :(得分:2)

最后,我得到了使用pjsip-2.4

发送带有自定义标头的短信的解决方案

这是代码

String msgBody = "sending message";
    SendInstantMessageParam prm = new SendInstantMessageParam();
 prm.setContent(msgBody);
 SipHeader hName = new SipHeader();
 hName.setHName("name");
 hName.setHValue(uniqueId);

 SipHeaderVector headerVector = new SipHeaderVector();
 headerVector.add(hName);
 SipTxOption option = new SipTxOption();
 option.setHeaders(headerVector);
 prm.setTxOption(option);
 try {

  myBuddy.sendInstantMessage(prm);
 } catch (Exception e) {
  e.printStackTrace();
 }