getWebsocketReadyState

[ Function ]

public static getWebsocketReadyState(): number | null;

Returns the current value of the web socket state. Instead of the number you should compare with the constant of the web socket object.

Parameter

Name

Type

Description

-

-

-

Return value

Type

Description

number, null

State value of the websocket.
null: The system is not yet fully loaded, therefore the connection is not yet established.
WebSocket.CONNECTING (0): The connection is not yet established.
WebSocket.OPEN (1): The connection is established and ready to communicate through it.
WebSocket.CLOSING (2): The connection is in the process of closing.
WebSocket.CLOSED (3): The connection is closed or could not be established.

getWebsocketReadyState 1:

Available from 1.8

Sample - JavaScript

var readyState = TcHmi.Server.getWebsocketReadyState();
if(readyState === WebSocket.OPEN){
    // Websocket is ready.
} else {
    // Websocket is not ready.
}

Sample 2 - JavaScript

This example is identical to the example shown above

var readyState = TcHmi.Server.getWebsocketReadyState();
if(readyState === 1){
    // Websocket is ready.
} else {
    // Websocket is not ready.
}