Skip to content

Commit

Permalink
Make IPeripheralConnection IAsyncDisposable
Browse files Browse the repository at this point in the history
  • Loading branch information
ssimek committed Nov 17, 2021
1 parent 8ade24a commit e9282d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public Task DisconnectAsync()
});
}

ValueTask IAsyncDisposable.DisposeAsync()
=> new ValueTask(DisconnectAsync());

public async Task<string> GetDeviceNameAsync()
{
var characteristic = await this.FindServiceCharacteristicAsync(ServiceCharacteristicUuid.GenericAccess.DeviceName);
Expand Down
2 changes: 1 addition & 1 deletion src/triaxis.Common.BluetoothLE/IPeripheralConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace triaxis.Maui.BluetoothLE
/// <summary>
/// Represents an active connection to a Bluetooth LE Peripheral
/// </summary>
public interface IPeripheralConnection
public interface IPeripheralConnection : IAsyncDisposable
{
/// <summary>
/// Disconnects from the peripheral
Expand Down
3 changes: 3 additions & 0 deletions src/triaxis.Common.BluetoothLE/iOS/PeripheralConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public Task DisconnectAsync()
});
}

ValueTask IAsyncDisposable.DisposeAsync()
=> new ValueTask(DisconnectAsync());

public Task<string> GetDeviceNameAsync()
=> Task.FromResult(_peripheral.Name);

Expand Down

0 comments on commit e9282d3

Please sign in to comment.