Options
Menu

Websocket API - Provides a handful of methods to receive messages for all or specific topics via the standard intrexx websocket.

Index

Functions

ping

  • ping(websocketAlias?: string): Promise<void | Error>
  • Send WebSocket PING to server.

    example
    ix.websocket.ping();
    

    Parameters

    • websocketAlias: string = "standard"

      Websocket alias otherwise the default intrexx websocket is used.

    Returns Promise<void | Error>

    Promise, is resolved if the server responds with a PONG, otherwise it will be rejected.

subscribeToTopic

  • subscribeToTopic(topic: string, subscriber: Partial<UpWebSocketSubscriber>, websocketAlias?: string): Promise<UpWebSocketSubscriber>
  • Subscribe for WebSocket messages with a specific topic key.

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

    Parameters

    • topic: string

      Identifier for a specitfic websocket topic.

    • subscriber: Partial<UpWebSocketSubscriber>

      Subscriber

    • websocketAlias: string = "standard"

      Websocket alias otherwise the default Intrexx websocket is used.

    Returns Promise<UpWebSocketSubscriber>

unsubscribeFromTopic

  • unsubscribeFromTopic(subscriber: string | UpWebSocketSubscriber, websocketAlias?: string): void
  • Unsubscribe for WebSocket messages.

    example
    ix.websocket.unsubscribeFromTopic(mySubscriber);
    
    example
    ix.websocket.unsubscribeFromTopic("<SUBSRIBER-KEY>");
    

    Parameters

    • subscriber: string | UpWebSocketSubscriber

      WebSocket subscriber object or subsriber key.

    • Optional websocketAlias: string

      Websocket alias otherwise the default Intrexx websocket is used.

    Returns void