我是SignalR
的新手,所以我可能会遗漏一些基本的东西。
使用时:
public class EventDispatcher : Hub
{
void Send(string sStrategyID, string sMessage)
{
var context = GlobalHost.ConnectionManager.GetHubContext<EventDispatcher>();
context.Clients.All.broadcastMessage(sStrategyID, sMessage);
}
}
客户识别eventDispatcher
但不识别broadcastMessage
。
$(function () {
var chat = $.connection.eventDispatcher;
chat.client.broadcastMessage = function (sStrategyID, sMessage) {
console.log("Id: " + sStrategyID + " ,Event: " + sMessage);
};
});