public async Task UnsubscribeFromLiveTrendbar(long accountId, bool isLive, long symbolId, ProtoOATrendbarPeriod period) { VerifyConnection(); var client = GetClient(isLive); using var cancelationTokenSource = new CancellationTokenSource(); ProtoOAUnsubscribeLiveTrendbarRes receivedResponse = null; using var disposable = client.OfType <ProtoOAUnsubscribeLiveTrendbarRes>().Where(response => response.CtidTraderAccountId == accountId) .Subscribe(response => { receivedResponse = response; cancelationTokenSource.Cancel(); }); var requestMessage = new ProtoOAUnsubscribeLiveTrendbarReq { CtidTraderAccountId = accountId, Period = period, SymbolId = symbolId }; await SendMessage(requestMessage, ProtoOAPayloadType.ProtoOaUnsubscribeLiveTrendbarReq, client, cancelationTokenSource, () => receivedResponse is not null); }
private void Process_Unsubscribe_Live_Trendbar_Res() { ProtoOAUnsubscribeLiveTrendbarRes args = Serializer.Deserialize <ProtoOAUnsubscribeLiveTrendbarRes>(_processorMemoryStream); Log.Info("ProtoOAUnsubscribeLiveTrendbarRes:: " + $"ctidTraderAccountId: {args.ctidTraderAccountId}"); OnUnsubscribeLiveTrendbarResReceived?.Invoke(args); }