Skip to content

Commit fd8f784

Browse files
authored
Merge pull request #1266 from ably/feature/status-async
Add async version of channel status
2 parents 42a100a + 1cb02fe commit fd8f784

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,6 @@ foreach (var presence in presenceHistory.Items)
280280
var presenceNextPage = await presenceHistory.NextAsync();
281281
```
282282

283-
### Getting the channel status
284-
285-
Getting the current status of a channel, including details of the current number of `Publishers`, `Subscribers` and `PresenceMembers` etc is simple
286-
287-
```csharp
288-
ChannelDetails details = channel.Status();
289-
ChannelMetrics metrics = details.Status.Occupancy.Metrics;
290-
// Do something with 'metrics.Publishers' etc
291-
```
292-
293283
### Symmetric end-to-end encrypted payloads on a channel
294284

295285
When a 128-bit or 256-bit key is provided to the library, all payloads are encrypted and decrypted automatically using that key on the channel. The secret key is never transmitted to Ably and thus it is the developer's responsibility to distribute a secret key to both publishers and subscribers.
@@ -445,6 +435,16 @@ var nextStatsPage = await stats.NextAsync();
445435
DateTimeOffset time = await client.TimeAsync();
446436
```
447437

438+
### Getting the channel status
439+
440+
Getting the current status of a channel, including details of the current number of `Publishers`, `Subscribers` and `PresenceMembers` etc is simple
441+
442+
```csharp
443+
ChannelDetails details = await channel.StatusAsync();
444+
ChannelMetrics metrics = details.Status.Occupancy.Metrics;
445+
// Do something with 'metrics.Publishers' etc
446+
```
447+
448448
### Making explicit HTTP requests to Ably Rest Endpoints / Batch publish
449449
- The `AblyRest->Request` method should be used to make explicit HTTP requests.
450450
- It automatically adds necessary auth headers based on the initial auth config and supports pagination.

src/IO.Ably.Shared/Rest/IRestChannel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public interface IRestChannel
4848
/// <returns><see cref="PaginatedResult{T}"/> of past Messages.</returns>
4949
Task<PaginatedResult<Message>> HistoryAsync(PaginatedRequestParams query);
5050

51+
/// <summary>
52+
/// Returns the active status for the channel including the number of publishers, subscribers and presenceMembers etc.
53+
/// </summary>
54+
/// <returns><see cref="ChannelDetails"/>Channel Details.</returns>
55+
Task<ChannelDetails> StatusAsync();
56+
5157
/// <summary>
5258
/// Name of the channel.
5359
/// </summary>
@@ -103,7 +109,8 @@ public interface IRestChannel
103109
PaginatedResult<Message> History(PaginatedRequestParams query);
104110

105111
/// <summary>
106-
/// Returns the active status for the channel including the number of publishers, subscribers and presenceMembers etc.
112+
/// Sync version of <see cref="StatusAsync()"/>.
113+
/// Prefer async version where possible.
107114
/// </summary>
108115
/// <returns><see cref="ChannelDetails"/>Channel Details.</returns>
109116
ChannelDetails Status();

src/IO.Ably.Shared/Rest/RestChannel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ public PaginatedResult<Message> History(PaginatedRequestParams query)
227227
return AsyncHelper.RunSync(() => HistoryAsync(query));
228228
}
229229

230-
private async Task<ChannelDetails> StatusAsync()
230+
/// <inheritdoc/>
231+
public async Task<ChannelDetails> StatusAsync()
231232
{
232233
AblyRequest request = _ablyRest.CreateGetRequest("/channels/" + Name);
233234
return await _ablyRest.ExecuteRequest<ChannelDetails>(request);

src/IO.Ably.Tests.Shared/Rest/ChannelSandboxSpecs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public async Task ChannelDetails_AreAvailable(Protocol protocol)
665665
AblyRest client = await GetRestClient(protocol);
666666
IRestChannel c = client.Channels.Get(Name);
667667

668-
ChannelDetails cd = c.Status();
668+
ChannelDetails cd = await c.StatusAsync();
669669
cd.ChannelId.Should().Be(Name);
670670
cd.Status.IsActive.Should().BeTrue();
671671

0 commit comments

Comments
 (0)