我正在编码SignalR Hub客户端以从Web服务获取数据,并且对于我在其服务器上调用的一个更重要的方法,我得到的消息不包含&#34; M:eventName&#34 ;我用来处理其他消息类型的那种行(只是&#34; R:[数据]和我:[0]&#34;)。当我启用跟踪时,我可以看到消息数据全部存在,但是如何在没有eventName的情况下处理它?</ p>
示例:
`HubProxy.On<DataClass>("???event-name-here???", update => Console.WriteLine("OUTPUT");`
消息跟踪:
23:02:34.9119843 - e1ef32d1-d374-4d7d-82b4-011d906cb096 - WS: OnMessage({"R":{"MarketName":null,"Nounce":136096,"Buys":[{"Quantity":1261.89236694,"Rate":0.00567987},{"Quantity":17.66436734,"Rate":0.00565000},{"Quantity":0.35424250,"Rate":0.00564585},{"Quantity":148.53138590,"Rate":0.00564100},{"Quantity":114.03031557,"Rate":0.00564000},{"Quantity":823.55802148,"Rate":0.00563998},{"Quantity":92.11307737,"Rate":0.00563997},{"Quantity":439.17714798,"Rate":0.00563990},{"Quantity":35.46237619,"Rate":0.00563978},{"Quantity":380.42279579,"Rate":0.00563777},{"Quantity":308.83819198,"Rate":0.00563600},{"Quantity":0.10951077,"Rate":0.00563433},{"Quantity":0.35548667,"Rate":0.00562609},{"Quantity":11.23857359,"Rate":0.00562082},{"Quantity":2.69321221,"Rate":0.00562011},{"Quantity":0.99414299,"Rate":0.00561891},{"Quantity":24.41591498,"Rate":0.00561500},{"Quantity":0.35673516,"Rate":0.00560640},{"Quantity":2.66949153,"Rate":0.00560500},{"Quantity":38.31222855,"Rate":0.00560000},{"Quantity":17.84436494,"Rate":0.00559000},{"Quantity":208.91357967,"Rate":0.00557050},{"Quantity":0.89792884,"Rate":0.00556837},{"Quantity":6.28868665,"Rate":0.00556555},{"Quantity":178.86139272,"Rate":0.00556301},{"Quantity":304.80171408,"Rate":0.00556300},{"Quantity":0.56409118,"Rate":0.00556122},{"Quantity":11.57184239,"Rate":0.00556069},{"Quantity":0.19164392,"Rate":0.00555933},{"Quantity":3.00000000,"Rate":0.00555560},{"Quantity":1579.01........
答案 0 :(得分:1)
看起来该消息不是客户端调用(您称之为“事件”),而是服务器调用的返回值。
使用返回值;在Invoke<T>
对象上使用Invoke
代替IHubProxy
。