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 |
---|---|
State value of the websocket. |
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.
}