Class JsSIP.NameAddrHeader

An instance of the JsSIP.NameAddrHeader class contains a “name-addr” or a “addr-spec” value as stated in the BNF grammar of the RFC 3261.

A “name-addr” value is in the form “display name <URI>”.

Example:

From: "Alice" <sip:alice@atlanta.com>

A “addr-spec” value is in the form “URI”.

Example:

From: sip:alice@atlanta.com

Instantiation

JsSIP.NameAddrHeader(uri, display_name=null, parameters=null)

Instantiation of this class will raise an exception if no uri value is passed.

Parameters

uri
JsSIP.URI instance.
display_name
Optional String indicating display name.
parameters
Optional Object with property values represented in String form. For empty parameters, a null value must be indicated.

Throws

Example

var parameters = {
  'parameter_1': 'value_1',
  'parameter_2': null
}
var header = new JsSIP.NameAddrHeader(uri, 'Mrs. Alice', parameters)

header.toString() // Returns '"Mrs. Alice" <sip:alice@atlanta.com>;parameter_1=value_1;parameter_2'

Instance Attributes

display_name

Set or get a String indicating the header display name.

Example

header.display_name = 'Mrs. Alice';

uri

Getter for the JsSIP.URI instance of this “name-addr”.

Example

header.display_name = 'Mrs. Alice';

Instance Methods

setParam(key, value=null)

Creates or replaces the given header parameter with given value.

Parameters

key
String indicating the parameter name.
value
Optional String indicating the parameter value.

Example

header.setParam('param_name', 'param_value');

getParam(key)

Gets the value of the given header parameter. Returns undefined if the parameter does not exist in the paramter set.

Parameters

key
String indicating the parameter name.

Example

header.setParam('param_name', 'param_value');
header.getParam('param_name'); // Returns 'param_value'

hasParam(key)

Verifies the existence of the given header parameter. Returns true if the parameter exists, false otherwise.

Parameters

key
String indicating the parameter name.

Example

header.setParam('param_name', 'param_value');
header.hasParam('param_name'); // Returns true

deleteParam(key)

Deletes the given parameter from the header.

Parameters

key
String indicating the parameter name.

Example

header.deleteParam('param_name');

clearParams()

Removes all the header parameters.

clone()

Returns a cloned JsSIP.NameAddrHeader instance of the header.

cloned_header = header.clone();
cloned_header === header // Returns false

toString()

Returns a String representing the header.

Characters that can’t appear unescaped are escaped as stated in the BNF grammar of the RFC 3261.

header.toString(); // Returns '"Mrs. Alice" <sip:alice@atlanta.com:5060>;param_name=param_value'

Module Functions

parse(nameAddrHeader)

Parses the given String against the name address header grammar rule. Returns a JsSIP.NameAddrHeader instance if parsing success, undefined otherwise.

Parameters

nameAddrHeader
String representing a name addresss header field value.

Example

var name_addr_hdr = JsSIP.NameAddrHeader.parse('"Mrs. Alice" <sip:alice@atlanta.com:5060>;param_name=param_value');