Method SetPersistentDataAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
SetPersistentDataAsync(ObsDataRealm, string, object, CancellationToken)
Puts data in a slot that OBS Studio keeps for an application, and returns when OBS Studio has answered.
public Task SetPersistentDataAsync(ObsDataRealm realm, string slotName, object value, CancellationToken cancellationToken = default)
Parameters
realmObsDataRealmWhere the slot is: for all profiles, or for the profile that is current.
slotNamestringThe name of the slot. A slot that does not exist is made.
valueobjectWhat to keep: text, a number, true or false, an object (for example
new { volume = 7 }), a list, or a JsonElement. It replaces what the slot held. It can not be null: OBS Studio takes a null for a value that is missing.cancellationTokenCancellationTokenA token that ends the wait. A change that was not sent yet is not sent.
Returns
- Task
A task that completes when OBS Studio has answered that it kept the data.
Remarks
OBS Studio writes the slots to a file at once, so they are kept when OBS Studio closes. It has no request that removes a slot, and a null is not kept (measured with OBS Studio 33.0.0: it refuses it as a missing field): put an empty value in the slot (an empty string, or an empty object) to say that there is nothing. Every program that is connected reads and writes the same slots: pick a name that is yours (see GetPersistentDataAsync(ObsDataRealm, string, CancellationToken)). The slots are not part of the model, so the call has nothing to wait for but the answer of OBS Studio. See SetEnabledAsync(bool, CancellationToken) for the order of changes.
Exceptions
- ArgumentNullException
valueis null.- ArgumentException
slotNameis empty, orvaluecan not be written as JSON, or is a JSON null.- ArgumentOutOfRangeException
realmis not a realm.- ObsNotConnectedException
There is no connection to OBS Studio. Nothing was changed.
- ObsNotReadyException
OBS Studio is changing its scene collection, or did so after the call. Nothing was changed.
- ObsUnknownOutcomeException
OBS Studio did not answer in time, or the connection ended: it is not known whether it kept the data.
- ObsResponseException
OBS Studio refused the change: it could not write the file that holds the slots (ErrorCode is RequestProcessingFailed).