Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Notifications/StreamingSubscriptionConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable
/// </summary>
private GetStreamingEventsRequest currentHangingRequest;

/// <summary>
/// Whether OnConnectionCompleted has been fired since last connect
/// </summary>
private bool hasFiredConnectionCompleted;

/// <summary>
/// Lock object
/// </summary>
Expand Down Expand Up @@ -87,6 +92,11 @@ public sealed class StreamingSubscriptionConnection : IDisposable
/// </summary>
public event SubscriptionErrorDelegate OnSubscriptionError;

/// <summary>
/// Occurs on the first response from the server, successfull or not.
/// </summary>
public event EventHandler OnConnectionCompleted;

/// <summary>
/// Occurs when a streaming subscription connection is disconnected from the server.
/// </summary>
Expand Down Expand Up @@ -215,6 +225,8 @@ public void Open()
throw new ServiceLocalException(Strings.NoSubscriptionsOnConnection);
}

this.hasFiredConnectionCompleted = false;

this.currentHangingRequest = new GetStreamingEventsRequest(
this.session,
this.HandleServiceResponseObject,
Expand Down Expand Up @@ -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)
Expand Down