• Subscribe for WebSocket messages with a specific topic key.

    Parameters

    • topic: string

      Identifier for a specific WebSocket topic.

    • subscriber: Partial<UpWebSocketSubscriber>

      WebSocket subscriber object or subscriber key.

    • websocketAlias: string = "standard"

      WebSocket alias, otherwise the default alias is used.

    Returns Promise<UpWebSocketSubscriber>

    Example

    Basic

    const mySubscriber = await ix.websocket.subscribeToTopic("<TOPIC-IDENTIFIER>", {
    onmessage: (data) => {
    console.log(data);
    }
    });

    Advanced

    const mySubscriber = await ix.websocket.subscribeToTopic("<TOPIC-IDENTIFIER>", {
    key: "key1",
    onmessageJSON: (data) => {
    console.log(data);
    },
    onerror: (error) => {
    console.log(error);
    },
    onclose: (event) => {
    console.log(event);
    }
    });