jssip - v3.14.0
    Preparing search index...

    Class URI

    Represents a SIP URI and provides a set of attributes and methods to retrieve and set the different parts of a URI.

    It can be represented in its full form, including parameters and headers, and in the AoR form. It can also be cloned, so a second URI can be formed from itself.

    const uri = new JsSIP.URI('sip', 'alice', 'example.com', 5060);

    uri.setParam('transport', 'ws');

    uri.toString(); // 'sip:alice@example.com:5060;transport=ws'
    uri.toAor(); // 'sip:alice@example.com'
    Index

    Constructors

    • Parameters

      • scheme: string | undefined

        URI scheme, sip when not given.

      • user: string | undefined

        User part of the URI, if any.

      • host: string

        Host part of the URI. The only mandatory one.

      • Optionalport: number | null

        Port of the URI, if any.

      • parameters: Parameters = {}

        URI parameters, added through URI.setParam.

      • headers: Headers = {}

        URI headers, added through URI.setHeader.

      Returns URI

      • TypeError if host is not given.

    Accessors

    • get scheme(): string

      Scheme of the URI, usually sip or sips.

      Returns string

    • set scheme(value: string): void

      Set the scheme of the URI, lowercasing the given value.

      Parameters

      • value: string

      Returns void

    • get user(): string | undefined

      User part of the URI, undefined when the URI has none.

      Returns string | undefined

    • set user(value: string | undefined): void

      Set the user part of the URI, or remove it by giving undefined.

      Parameters

      • value: string | undefined

      Returns void

    • get host(): string

      Host part of the URI, either a domain or an IP address.

      Returns string

    • set host(value: string): void

      Set the host part of the URI, lowercasing the given value.

      Parameters

      • value: string

      Returns void

    • get port(): number | null | undefined

      Port of the URI, null when the URI has none.

      Returns number | null | undefined

    • set port(value: string | number | null | undefined): void

      Set the port of the URI.

      Parameters

      • value: string | number | null | undefined

      Returns void

      • A string is accepted and converted into a number. A value that is not a number becomes null.

    Methods

    • Parse the given string into a URI.

      Parameters

      • uri: string

      Returns URI | undefined

      undefined if the string is not a valid SIP URI.

      const uri = JsSIP.URI.parse('sip:alice@example.com');
      
    • Set the given URI parameter.

      Parameters

      • key: string

        Parameter name, lowercased.

      • Optionalvalue: string | number | null

        Parameter value. A parameter with no value, such as the lr of a loose route, is set by giving null or nothing.

      Returns void

      uri.setParam('transport', 'ws');
      uri.setParam('lr');
    • Get the value of the given URI parameter.

      Parameters

      • key: string

      Returns string | null | undefined

      null if the parameter has no value, undefined if the URI does not have it.

    • Whether the URI has the given parameter.

      Parameters

      • key: string

      Returns boolean | undefined

      undefined if no parameter name is given.

    • Remove the given URI parameter.

      Parameters

      • parameter: string

      Returns string | null | undefined

      The value it had, null if it had none, undefined if the URI did not have the parameter.

    • Remove every URI parameter.

      Returns void

    • Set the given URI header.

      Parameters

      • name: string

        Header field name, which gets capitalized as it is written in SIP messages.

      • value: string | string[]

        A single value or several of them.

      Returns void

    • Get the values of the given URI header.

      Parameters

      • name: string

      Returns string[] | undefined

      undefined if the URI does not have it.

    • Whether the URI has the given header.

      Parameters

      • name: string

      Returns boolean | undefined

      undefined if no header name is given.

    • Remove the given URI header.

      Parameters

      • header: string

      Returns string[] | undefined

      The values it had, undefined if the URI did not have the header.

    • Remove every URI header.

      Returns void

    • A copy of the URI that shares nothing with it, so that either can be modified without affecting the other.

      Returns URI

    • The URI as it is written in a SIP message, with its parameters and headers.

      Returns string

      uri.toString(); // 'sip:alice@example.com:5060;transport=ws'
      
    • The address of record of the URI, so its scheme, user and host without any parameter nor header.

      Parameters

      • Optionalshow_port: boolean

        Whether to include the port, which is left out by default.

      Returns string

      uri.toAor(); // 'sip:alice@example.com'
      uri.toAor(true); // 'sip:alice@example.com:5060'