public async Task <ProtoOAAsset[]> GetAssets(long accountId, bool isLive) { VerifyConnection(); var client = GetClient(isLive); using var cancelationTokenSource = new CancellationTokenSource(); ProtoOAAsset[] result = null; using var disposable = client.OfType <ProtoOAAssetListRes>().Where(response => response.CtidTraderAccountId == accountId).Subscribe(response => { result = response.Asset.ToArray(); cancelationTokenSource.Cancel(); }); var requestMessage = new ProtoOAAssetListReq { CtidTraderAccountId = accountId, }; await SendMessage(requestMessage, ProtoOAPayloadType.ProtoOaAssetListReq, client, cancelationTokenSource, () => result is not null); return(result); }
public static ProtoMessage Asset_List_Req(long ctidTraderAccountId) { ProtoOAAssetListReq message = new ProtoOAAssetListReq { payloadType = ProtoOAPayloadType.ProtoOaAssetListReq, ctidTraderAccountId = ctidTraderAccountId }; Log.Info("ProtoOAAssetListReq:: " + $"ctidTraderAccountId: {ctidTraderAccountId}"); InnerMemoryStream.SetLength(0); Serializer.Serialize(InnerMemoryStream, message); return(Encode((uint)message.payloadType, InnerMemoryStream.ToArray())); }