2
獲取返回值我都用的請求發送到特定的客戶端,然後得到一個返回值的方法SignalR。我知道這是不可能的,但客戶端需要將響應作爲單獨的消息發送到集線器。從SignalR客戶
我將消息發送到客戶端從輪轂外:
public String GetResponseFromUser(String userId, String request)
{
// Use requestId to be sure the response is on this request
var requestId = Guid.NewGuid().ToString();
var hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
hubContext.Clients.User(userId).Request(requestId, request);
// Wait for client to send response to the Hub's Response method
var response = ...?
return response;
}
HUB類
public class MyHub : Hub
{
public void Response(String requestId, String response)
{
// Somehow I want to get the response to the method above
}
}
我如何可以等待客戶端的響應,並在我的方法使用該響應的樞紐外?
太好了!那是我錯過的方法! – 2014-12-03 07:57:01
但抱歉,在IHubContext中找不到On方法。 – 2014-12-03 19:39:25