Method ConnectAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
ConnectAsync(string, int, string, CancellationToken)
Connects to OBS Studio, and reads its scenes, inputs and scene items. The task completes when the model is complete.
public Task ConnectAsync(string hostname = "localhost", int port = 4455, string password = "", CancellationToken cancellationToken = default)
Parameters
hostnamestringThe name or address of the computer that OBS Studio runs on.
portintThe port of the WebSocket server of OBS Studio.
passwordstringThe password of the WebSocket server, or empty when it has none.
cancellationTokenCancellationTokenA token that ends the attempt.
Returns
Remarks
When it fails, nothing is left connected, and nothing keeps trying. After it succeeds, the connection is restored when it is lost (AutoReconnect), and the model is read again.
Exceptions
- InvalidOperationException
The model is connected or connecting already.
- ObjectDisposedException
The ObsModel is disposed.
- ObsNotConnectedException
OBS Studio could not be reached, refused the password, or the connection ended before the model was complete.
- ObsVersionNotSupportedException
OBS Studio is older than 30.1.
- TimeoutException
The model was not complete within SynchronizationTimeout.
- OperationCanceledException
cancellationTokenwas cancelled, or DisconnectAsync() was called, or the ObsModel was disposed, while it was connecting.