46 lines
1.3 KiB
Markdown
46 lines
1.3 KiB
Markdown
# The taClient.isConnected() method
|
|
This documents the `taClient.isConnected()` method.
|
|
|
|
<div class="info-box">
|
|
<span class="material-icons">info</span>
|
|
<div>
|
|
<strong>Synchronous:</strong> This is a synchronous method that does not require await
|
|
</div>
|
|
</div>
|
|
|
|
This method has no input parameters. The function could easily be defined as:
|
|
```ts
|
|
function isConnected(): boolean {
|
|
// backend logic
|
|
}
|
|
```
|
|
|
|
## General usage:
|
|
```ts
|
|
const isConnected: boolean = taClient.isConnected();
|
|
```
|
|
|
|
If you have not yet, please read [Client -> Introduction to the Client](/documentation#Client/3-client-intro)
|
|
|
|
## 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:
|
|
```ts
|
|
// 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");
|
|
}
|
|
```
|
|
|
|
<div class="info-box">
|
|
<span class="material-icons">info</span>
|
|
<div>
|
|
<strong>Best Practice:</strong> Always check if the client is connected before attempting to perform operations that require a server connection.
|
|
</div>
|
|
</div>
|