tsdoc
    Preparing search index...

    Function init

    • Initialize a websocket on the given client identifier. When connected, it will stay open and reconnect as long as URL is valid and faces.push.close hasn't explicitly been called on the same client identifier.

      Parameters

      • clientId: string

        The client identifier of the websocket.

      • url: string

        The URL of the websocket. All open websockets on the same URL will receive the same push notification from the server.

      • channel: string

        The channel name of the websocket.

      • onopen: string | Function

        The JavaScript event handler function that is invoked when the websocket is opened. The function will be invoked with one argument: the channel name.

      • onmessage: string | Function

        The JavaScript event handler function that is invoked when a message is received from the server. The function will be invoked with three arguments: the push message, the channel name and the raw MessageEvent itself.

      • onerror: string | Function

        The JavaScript event handler function that is invoked when a connection error has occurred and the web socket will attempt to reconnect. The function will be invoked with three arguments: the error reason code, the channel name and the raw CloseEvent itself. Note that this will not be invoked on final close of the web socket, even when the final close is caused by an error. See also RFC 6455 section 7.4.1 and jakarta.websocket.CloseReason.CloseCodes API for an elaborate list of all close codes.

      • onclose: string | Function

        The function to be invoked when the web socket is closed and will not anymore attempt to reconnect. The function will be invoked with three arguments: the close reason code, the channel name and the raw CloseEvent itself. Note that this will also be invoked when the close is caused by an error and that you can inspect the close reason code if an actual connection error occurred and which one (i.e. when the code is not 1000 or 1008). See also RFC 6455 section 7.4.1 and jakarta.websocket.CloseReason.CloseCodes API for an elaborate list of all close codes.

      • behaviors: object

        Client behavior functions to be invoked when specific message is received.

      • autoconnect: boolean

        Whether or not to automatically connect the socket. Defaults to false.

      Returns void

      2.3