Class StreamingSession
ストリーミングセッション。await foreach で (Topic, Payload) を受け取ります。
public sealed class StreamingSession : IAsyncEnumerable<(string? Topic, Payload Payload)>
- Inheritance
-
StreamingSession
- Implements
- Inherited Members
Examples
var topics = new HashSet<string> { Topic.DmUpdate($"{myId}-{userId}") };
var session = await client.GetStreamingSessionAsync(topics);
await foreach (var (topic, payload) in session)
{
if (payload.DmUpdate is { } dm) Console.WriteLine($"{dm.ConversationId}: {dm.UserId} sent a message");
}
Constructors
StreamingSession(Client, string, IAsyncEnumerator<(string? Topic, Payload Payload)>, IEnumerable<string>, bool)
public StreamingSession(Client client, string sessionId, IAsyncEnumerator<(string? Topic, Payload Payload)> stream, IEnumerable<string> topics, bool autoReconnect)
Parameters
clientClientsessionIdstringstreamIAsyncEnumerator<(string Topic, Payload Payload)>topicsIEnumerable<string>autoReconnectbool
Properties
AutoReconnect
切断時に自動で再接続するか。
public bool AutoReconnect { get; set; }
Property Value
Id
セッションの ID。
public string Id { get; }
Property Value
Topics
ストリーム中のトピック。
public HashSet<string> Topics { get; }
Property Value
Methods
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<(string? Topic, Payload Payload)> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken that may be used to cancel the asynchronous iteration.
Returns
- IAsyncEnumerator<(string Topic, Payload Payload)>
An enumerator that can be used to iterate asynchronously through the collection.
ReconnectAsync()
セッションを再接続します。最初に受け取った config イベントを返します。
public Task<(string? Topic, Payload Payload)> ReconnectAsync()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
UpdateSubscriptionsAsync(ISet<string>?, ISet<string>?)
トピックの購読を更新します。
public Task<Payload> UpdateSubscriptionsAsync(ISet<string>? subscribe = null, ISet<string>? unsubscribe = null)