TsgcWebSocketClient › Methods › Disconnect
Closes the WebSocket connection synchronously and blocks the caller until the disconnection completes or the timeout elapses.
public bool Disconnect(int aTimeout = 10000);
| Name | Type | Description |
|---|---|---|
aTimeout | const Integer | Maximum time in milliseconds to wait for the connection to be closed. Defaults to 10000 (10 seconds). |
True when the client has been fully disconnected within the timeout; False if the timeout expired first. (Boolean)
Disconnect is the blocking counterpart to setting Active := False. It clears Active and then waits on an internal event until the disconnect handshake finishes or the timeout fires. If the client is already disconnected, the method returns True immediately. When Options.CleanDisconnect is enabled, a WebSocket close frame is sent to the server before the socket is torn down. Use Stop instead when you need a non-blocking disconnect from a secondary thread.
if (oClient.Disconnect(10000) == true)
ShowMessage("Disconnected");
else
ShowMessage("Not Disconnected");