简体   繁体   English

是否可以从javascript客户端同步调用Signalr服务器端方法?

[英]Is it possible to synchronously call Signalr server side method from javascript client?

我想从javascript调用服务器中心方法并使用javascript代码块,直到服务器端方法返回(一些数据)为止-这可能吗?

No. It is not possible to make the SignalR JS client block for hub method invocations. 不可以。无法使SignalR JS客户端块进行集线器方法调用。

The only option is to use the jQuery promise which is returned immediately by SignalR after it starts invoking the hub method. 唯一的选择是使用SignalR在开始调用hub方法后立即返回的jQuery Promise。 The then , done , fail , etc... methods allow you to add handlers that run after the hub invocation has completed. thendonefail等方法允许您添加在中心调用完成后运行的处理程序。

You can learn more by reading the SignalR Hubs API Guide for the JS client . 您可以阅读JS客户端SignalR Hubs API指南,了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 非MVC项目中来自客户端的SignalR服务器端方法调用 - SignalR Server side method call from Client side in Non MVC project SignalR - 用于检测客户端是否与集线器断开连接的服务器端方法? - SignalR - Server side method to detect if a client disconnects from a hub? SignalR:我无法从服务器调用 .net 客户端方法 - SignalR: I cannot call .net client method from server 从 JavaScript 客户端调用服务器上的方法时出现 SignalR 错误 - SignalR error when invoking method on the server from JavaScript client 如何从客户端 JavaScript function 调用服务器方法背后的代码? - How to call code behind server method from a client side JavaScript function? 从客户端调用方法 - To call a method from client side 从服务器端发送到客户端时,SignalR消息不起作用 - SignalR message not working when sending from server side to client signalR调用服务器方法,该方法调用集线器外部的回调方法。 如何从该方法调用客户端功能? - signalR calls a server method and that method calls a callback method ,outside the hub. How can I call client function from that method? 调用服务器端从javascript继承C#Web方法 - call server side inherited C# web method from javascript SignalR服务器 - >客户端呼叫无法正常工作 - SignalR server --> client call not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM