本文介绍了SignalR集线器上下文不返回消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嘿伙计们,我只是想知道是否有人可以帮助我。我有一个Windows服务,它在我的Web应用程序中调用hub类。我的问题是,当我创建集线器上下文并调用显示消息时,消息不会显示。初始连接很好,我可以从提琴手看到集线器已连接。 服务代码 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 ,连接); }); }); 该服务也在同一个解决方案中,我将其作为控制台应用程序运行以进行测试。任何帮助都是非常吝啬的人。解决方案 .connection.dbHub; hub.client.displayMessage = function(){ alert(Success); }; 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. 解决方案 这篇关于SignalR集线器上下文不返回消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!