// Called when the web socket establishes a connection private void OnConnect(object sender, EventArgs args) { if (_cts.IsCancellationRequested) { Log.To.ChangeTracker.I(Tag, "{0} Cancellation requested, aborting in OnConnect", this); return; } Misc.SafeDispose(ref _responseLogic); _responseLogic = new WebSocketLogic(); _responseLogic.OnCaughtUp = () => Client?.ChangeTrackerCaughtUp(this); _responseLogic.OnChangeFound = (change) => { if (!ReceivedChange(change)) { Log.To.ChangeTracker.W(Tag, String.Format("change is not parseable")); } }; Backoff.ResetBackoff(); Log.To.ChangeTracker.V(Tag, "{0} websocket opened", this); // Now that the WebSocket is open, send the changes-feed options (the ones that would have // gone in the POST body if this were HTTP-based.) var bytes = GetChangesFeedPostBody().ToArray(); _client?.SendAsync(bytes, null); }
public WebSocketChangeTracker(ChangeTrackerOptions options) : base(options) { _responseLogic = new WebSocketLogic(); CanConnect = true; }