diff --git a/Notifications/StreamingSubscriptionConnection.cs b/Notifications/StreamingSubscriptionConnection.cs index fdef52fb..da84e95e 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,13 @@ private void HandleServiceResponseObject(object response) } else { + if (!hasFiredConnectionCompleted) + { + EventHandler onConnectionCompleted = OnConnectionCompleted; + if (onConnectionCompleted != null) + onConnectionCompleted(this, new EventArgs()); + hasFiredConnectionCompleted = true; + } if (gseResponse.Result == ServiceResult.Success || gseResponse.Result == ServiceResult.Warning) { if (gseResponse.Results.Notifications.Count > 0)