我有一个自己托管的信号中心和两种类型的客户端连接到它。保持连接活着以正确的方式从c#客户端
Web应用程序:我可以保持连接状态,当你看到下面使用断开事件:
$(function() { $.connection.hub.url = "http://localhost:8080/signalr"; // Declare a proxy to reference the hub. var priceHub = $.connection.uTHub; $.connection.hub.start(); $.connection.hub.disconnected(function() { setTimeout(function() { $.connection.hub.start(); }, 2000); // Restart connection after 2 seconds. }); });
的Windows服务:
hubConnection = new HubConnection("http://localhost:8080/signalr", "source=" + feed, useDefaultUrl: false); priceProxy = hubConnection.CreateHubProxy("UTHub"); hubConnection.Start().Wait();
在windows服务,如何我可以处理断开的事件(2秒后重新启动连接行为),正如我在Web应用程序中使用的那样?
由于提前,
http://www.asp.net/signalr/overview/guide-to-the-api/handling-connection-lifetime-events#keepalive这个逻辑已经在你的问题中提及过了。你试图解决什么? – Artiom
是的我知道我在我的集线器的Web应用程序客户端中拥有该逻辑。我需要与我的集线器的Windows服务客户端相同的逻辑。 – anilca
答案 - 这是不可能的。 – Artiom