ShyyTAUI/src/lib/taDocs/3-client-isConnected.md

1.3 KiB

The taClient.isConnected() method

This documents the taClient.isConnected() method.

info
Synchronous: This is a synchronous method that does not require await

This method has no input parameters. The function could easily be defined as:

function isConnected(): boolean {
    // backend logic
}

General usage:

const isConnected: boolean = taClient.isConnected();

If you have not yet, please read Client -> Introduction to the Client

Return Value:

This method returns a boolean value:

  • true: The client is currently connected to a TA Core Server
  • false: The client is not currently connected to a TA Core Server

Example usage:

// Check if the client is connected before performing operations
if (taClient.isConnected()) {
    // Perform operations that require a connection
    const response = await taClient.createMatch(tournamentGuid, matchData);
} else {
    console.log("Not connected to the TA server");
}
info
Best Practice: Always check if the client is connected before attempting to perform operations that require a server connection.