Skip to content
Permalink
Browse files

Add AllRequestFilters to SSE Client

  • Loading branch information...
mythz committed Aug 1, 2019
1 parent 07e2274 commit d0e39482381afd7401377b79f95519a93acdacfa
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/ServiceStack.Client/ServerEventsClient.cs
@@ -169,6 +169,8 @@ public string EventStreamUri
public Action<WebRequest> HeartbeatRequestFilter { get; set; }
public Action<WebRequest> UnRegisterRequestFilter { get; set; }

public Action<WebRequest> AllRequestFilters { get; set; }

readonly Dictionary<string, List<Action<ServerEventMessage>>> listeners =
new Dictionary<string, List<Action<ServerEventMessage>>>();

@@ -207,6 +209,12 @@ public ServerEventsClient Start()
httpReq.AllowReadStreamBuffering = false;

EventStreamRequestFilter?.Invoke(httpReq);
if (AllRequestFilters != null)
{
AllRequestFilters(httpReq);
if (ServiceClient is ServiceClientBase scb)
scb.RequestFilter = AllRequestFilters;
}

response = (HttpWebResponse)PclExport.Instance.GetResponse(httpReq);
var stream = response.ResponseStream();
@@ -324,6 +332,7 @@ protected void Heartbeat(object state)
req.CookieContainer = hold.CookieContainer;

HeartbeatRequestFilter?.Invoke(req);
AllRequestFilters?.Invoke(req);

if (log.IsDebugEnabled)
log.Debug("[SSE-CLIENT] Sending Heartbeat...");
@@ -767,6 +776,7 @@ public virtual Task InternalStop()
log.Debug("[SSE-CLIENT] Unregistering...");

UnRegisterRequestFilter?.Invoke(req);
AllRequestFilters?.Invoke(req);
});
} catch (Exception) {}
}

0 comments on commit d0e3948

Please sign in to comment.
You can’t perform that action at this time.