SignalR集线器上下文不返回消息。 [英] SignalR hub context not returning message.
问题描述
服务代码
var context = GlobalHost.ConnectionManager.GetHubContext< ClientNotificationsHub>();
context.Clients.All.DisplayMessage();
客户代码
$(function(){
var hub = $ .connection.dbHub;
hub.client.displayMessage = function(){
alert(成功);
};
$ .connection.hub.start()。done(function(){
var userId =''< %=会话(iUserId)%>'';
var connection =''<%=会话(sDBConnection)%>'';
hub.server.setConnection(userId ,连接);
});
});
该服务也在同一个解决方案中,我将其作为控制台应用程序运行以进行测试。任何帮助都是非常吝啬的人。
(function(){
var hub =
< blockquote> .connection.dbHub;
hub.client.displayMessage = function(){
alert(Success);
};
.connection.hub.start()。done(function(){
var userId =''<%= Session(iUserId)%>'';
var connection =''<%= Session(sDBConnection)%>'';
hub.server.setConnection(userId,connection);
});
}) ;
该服务也在同一个解决方案中,我将其作为控制台应用程序运行以进行测试。任何帮助都是非常苛刻的人。
Hey guys, I''m just wondering if anyone can help me. I have a windows service which calls the hub class in my web application. My problem is that when I create the hub context and call the display message the messages don''t get displayed. The initial connection is fine and I can see from fiddler that the hub is connected.
Service code
var context = GlobalHost.ConnectionManager.GetHubContext<ClientNotificationsHub>();
context.Clients.All.DisplayMessage();
Client code
$(function () { var hub = $.connection.dbHub; hub.client.displayMessage = function () { alert("Success"); }; $.connection.hub.start().done(function () { var userId = ''<%=Session("iUserId")%>''; var connection = ''<%=Session("sDBConnection")%>''; hub.server.setConnection(userId, connection); }); });
The service is also in the same solution and I have it running as a console app for testing purposes. Any help is very much apreciated guys.
(function () { var hub =
.connection.dbHub; hub.client.displayMessage = function () { alert("Success"); };
.connection.hub.start().done(function () { var userId = ''<%=Session("iUserId")%>''; var connection = ''<%=Session("sDBConnection")%>''; hub.server.setConnection(userId, connection); }); });
The service is also in the same solution and I have it running as a console app for testing purposes. Any help is very much apreciated guys.
这篇关于SignalR集线器上下文不返回消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!