连接参数

问题描述 投票:1回答:1

我想从https://github.com/simplefx-ltd/simplefx-api得到以下工作

Request:

{
 "H":"quotessubscribehub",
 "M":"getLastPrices",
 "A":[["BTCUSD","LTCUSD","ETHUSD","TLRY.US","GWPH.US"]],
 "I":0
}
hub - quotessubscribehub
method - getLastPrices
arguments:
0 - list of instruments - ["BTCUSD","LTCUSD","ETHUSD","TLRY.US","GWPH.US"]

我在c#中的第一次尝试如下:

 [Command]
    public async void LiveTrades()
    {           
        var trades = new List<String>() { "BTCUSD", "LTCBTC" };

        var hubConnection = new HubConnection("https://webquotes-v3.simplefx.com/signalr/");
            IHubProxy stockTickerHubProxy = hubConnection.CreateHubProxy("quotessubscribehub");
            hubConnection.Headers.Add("H", "quotessubscribehub");
            hubConnection.Headers.Add("M", "getLastPrices");
            hubConnection.Headers.Add("A", trades.ToString());
            hubConnection.Headers.Add("I", "0");

        stockTickerHubProxy.On<LiveSymbols>("getLastPrices", stock => TradePrice = stock.R.Data.ToString());
        await hubConnection.Start();        

    }

我不是100%,但也许参数列表导致我的主要问题。任何帮助都将被感激地接受。非常感谢斯科特

**编辑:看起来我现在有正确的文书清单。

var trades = new List<String>() { "BTCUSD", "LTCBTC" };
string output = new JavaScriptSerializer().Serialize(trades);

返回[“BTCUSD”,“LTCBTC”]

连接似乎很好,但没有向我返回任何项目。会继续努力

c# asp.net signalr
1个回答
0
投票

这解决了它。

var trades = new List<String>() { "BTCUSD", "LTCBTC" };
await hubConnection.Start();
var returnValue = await stockTickerHubProxy.Invoke<R>("getLastPrices", trades);
© www.soinside.com 2019 - 2024. All rights reserved.