jssip - v3.14.0
    Preparing search index...

    Interface Socket

    Abstracts the library from the mechanism used to send and receive SIP traffic.

    Implementations must follow this interface in order to get the library working with the underlying transport mechanism, and are given to the UA in its sockets configuration parameter.

    const socket = new JsSIP.WebSocketInterface('wss://sip.example.com');
    const ua = new JsSIP.UA({ sockets: socket, uri: 'sip:alice@example.com' });
    interface Socket {
        url: string;
        sip_uri: string;
        via_transport: string;
        connect(): void;
        disconnect(): void;
        send(
            message:
                | string
                | ArrayBufferLike
                | ArrayBufferView<ArrayBufferLike>
                | Blob,
        ): boolean;
        isConnected(): boolean;
        isConnecting(): boolean;
        onconnect(): void;
        ondisconnect(error: boolean, code?: number, reason?: string): void;
        ondata(data: string | ArrayBuffer): void;
    }

    Implemented by

    Index

    Properties

    url: string

    URI of the remote peer, as given to the implementation. Only used for logging.

    sip_uri: string

    SIP URI of the socket, used to build the Route header field of outgoing requests when the UA is configured with a preloaded route (for example sip:sip.example.com:443;transport=ws).

    via_transport: string

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

    Methods

    • Called by the library when the socket availability for sending and receiving data is required.

      Returns void

    • Called by the library when the socket is no longer needed for now.

      Returns void

      • Event handlers called after this one are ignored.
    • Called by the library when the given data needs to be sent.

      Parameters

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

      Returns boolean

      true if the data was successfully sent, false otherwise.

    • Whether the transport is up and able to send.

      Returns boolean

    • Whether the transport is in the middle of connecting.

      Returns boolean

    • Must be called when the socket becomes usable for sending and receiving data, after Socket.connect was called or an unsolicited disconnection occurred.

      Returns void

      • Assigned by the library. The application must not call it.
    • Must be called when the socket becomes unusable for sending or receiving data.

      Parameters

      • error: boolean

        Whether the socket disconnected due to an error.

      • Optionalcode: number

        Socket disconnection code, if any.

      • Optionalreason: string

        Socket disconnection reason, if any.

      Returns void

      • Assigned by the library. The application must not call it.
    • Must be called when there is a full SIP message to be processed by the library.

      Parameters

      • data: string | ArrayBuffer

      Returns void

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