Search code examples
c#sipfreeswitch

How to set displayName when registering a SIP account in c#


I try to register a SIP account. The registration is successful (to freeswitch). However, I would love to add a display name of the account. How do I do that? The documentation of Freeswitch is unclear about this. I have tried it this way:

 AccountConfig acfg = new AccountConfig();
            acfg.idUri = "sip:" + Account + "@" + Domain;
            pjsua2.SipHeader header = new pjsua2.SipHeader();
            header.hName = "displayName";
            header.hValue = "Dit is de persoon die als account: " + Account;
            acfg.regConfig.headers.Add(header);

But this is unsuccessful. I am pretty sure I have to add the display name by adding a header but I think I use the wrong one. I do not receive an error using the code above.


Solution

  • Based on RFC3261:

    The following are examples of valid To header fields:

     To: The Operator <sip:operator@cs.columbia.edu>;tag=287447
     t: sip:+12125551212@server.phone2net.com
    

    So you've to embed your SIP-URI into < and > and put your display name in front of it. Since to- and from-URI have to be the same when doing a SIP REGISTER you also have to set the from-URI. So you should change your code to:

            AccountConfig acfg = new AccountConfig();
            acfg.idUri = $"{YourDisplayNameHere} <sip: {Account}@{Domain}>";
            ...
    

    Since I'm not familiar with PJSIP you need to check if you've to set to-/from-URI for the SIP REGISTER in an additional way.

    Hope that helps.