jssip - v3.14.0
    Preparing search index...

    Class WebSocketInterface

    Built-in Socket implementation for browser environments, as defined by RFC 7118.

    • The underlying WebSocket is negotiated with the sip subprotocol, so the server must support it.
    const socket = new JsSIP.WebSocketInterface('wss://sip.example.com');
    const ua = new JsSIP.UA({ sockets: socket, uri: 'sip:alice@example.com' });

    ua.start();

    Implements

    Index

    Constructors

    • Parameters

      • url: string

        WebSocket URI of the SIP server, whose scheme must be ws or wss.

      Returns WebSocketInterface

      • TypeError if the URI is malformed or its scheme is neither ws nor wss.
      const socket = new JsSIP.WebSocketInterface('wss://sip.example.com:8443/ws');
      

    Properties

    onconnect: () => void

    Called once the WebSocket is open.

    • Assigned by the library. The application must not call it.
    ondisconnect: (error: boolean, code?: number, reason?: string) => void

    Called once the WebSocket is closed, cleanly or not.

    • Assigned by the library. The application must not call it.
    ondata: (data: string | ArrayBuffer) => void

    Called for every message received over the WebSocket.

    • Assigned by the library. The application must not call it.

    Accessors

    • get via_transport(): string

      The transport announced in the Via header field of outgoing requests, derived from the scheme of the given URI. Always uppercase.

      Returns string

      `WSS`
      
    • set via_transport(value: string): void

      Transport protocol to announce in the Via header field of outgoing requests (for example WSS).

      Parameters

      • value: string

      Returns void

    • get sip_uri(): string

      The SIP URI of the server, derived from the host and port of the given WebSocket URI.

      Returns string

      `sip:sip.example.com:8443;transport=ws`
      

    Methods

    • Send a SIP message over the WebSocket.

      Parameters

      • message: string | ArrayBufferLike | ArrayBufferView<ArrayBufferLike> | Blob

      Returns boolean

      Whether the message was handed to the WebSocket, so false if it is not open.