Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 6e2028d

Browse files
committed
Add event for when a StreamingSubscriptionConnection gets the first reply.
1 parent 812974b commit 6e2028d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Notifications/StreamingSubscriptionConnection.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable
5858
/// </summary>
5959
private GetStreamingEventsRequest currentHangingRequest;
6060

61+
/// <summary>
62+
/// Whether OnConnectionCompleted has been fired since last connect
63+
/// </summary>
64+
private bool hasFiredConnectionCompleted;
65+
6166
/// <summary>
6267
/// Lock object
6368
/// </summary>
@@ -87,6 +92,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable
8792
/// </summary>
8893
public event SubscriptionErrorDelegate OnSubscriptionError;
8994

95+
/// <summary>
96+
/// Occurs on the first response from the server, successfull or not.
97+
/// </summary>
98+
public event EventHandler OnConnectionCompleted;
99+
90100
/// <summary>
91101
/// Occurs when a streaming subscription connection is disconnected from the server.
92102
/// </summary>
@@ -215,6 +225,8 @@ public void Open()
215225
throw new ServiceLocalException(Strings.NoSubscriptionsOnConnection);
216226
}
217227

228+
this.hasFiredConnectionCompleted = false;
229+
218230
this.currentHangingRequest = new GetStreamingEventsRequest(
219231
this.session,
220232
this.HandleServiceResponseObject,
@@ -317,6 +329,11 @@ private void HandleServiceResponseObject(object response)
317329
}
318330
else
319331
{
332+
if (!hasFiredConnectionCompleted)
333+
{
334+
OnConnectionCompleted?.Invoke(this, new EventArgs());
335+
hasFiredConnectionCompleted = true;
336+
}
320337
if (gseResponse.Result == ServiceResult.Success || gseResponse.Result == ServiceResult.Warning)
321338
{
322339
if (gseResponse.Results.Notifications.Count > 0)

0 commit comments

Comments
 (0)