From 6e2028dbb780d4cb54e487afc3255e2bc1d21fad Mon Sep 17 00:00:00 2001 From: "Kasper F. Brandt" Date: Wed, 13 Sep 2017 16:48:22 +0200 Subject: [PATCH] Add event for when a StreamingSubscriptionConnection gets the first reply. --- .../StreamingSubscriptionConnection.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Notifications/StreamingSubscriptionConnection.cs b/Notifications/StreamingSubscriptionConnection.cs index fdef52fb..cdf96c66 100644 --- a/Notifications/StreamingSubscriptionConnection.cs +++ b/Notifications/StreamingSubscriptionConnection.cs @@ -58,6 +58,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable /// private GetStreamingEventsRequest currentHangingRequest; + /// + /// Whether OnConnectionCompleted has been fired since last connect + /// + private bool hasFiredConnectionCompleted; + /// /// Lock object /// @@ -87,6 +92,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable /// public event SubscriptionErrorDelegate OnSubscriptionError; + /// + /// Occurs on the first response from the server, successfull or not. + /// + public event EventHandler OnConnectionCompleted; + /// /// Occurs when a streaming subscription connection is disconnected from the server. /// @@ -215,6 +225,8 @@ public void Open() throw new ServiceLocalException(Strings.NoSubscriptionsOnConnection); } + this.hasFiredConnectionCompleted = false; + this.currentHangingRequest = new GetStreamingEventsRequest( this.session, this.HandleServiceResponseObject, @@ -317,6 +329,11 @@ private void HandleServiceResponseObject(object response) } else { + if (!hasFiredConnectionCompleted) + { + OnConnectionCompleted?.Invoke(this, new EventArgs()); + hasFiredConnectionCompleted = true; + } if (gseResponse.Result == ServiceResult.Success || gseResponse.Result == ServiceResult.Warning) { if (gseResponse.Results.Notifications.Count > 0)