C# 与API的信令连接
我在c#中设置了一个web api。它检查它是否仍然与信号机连接,并根据需要执行代码。这是我的情况:C# 与API的信令连接,c#,api,signalr,signalr-hub,signalr.client,C#,Api,Signalr,Signalr Hub,Signalr.client,我在c#中设置了一个web api。它检查它是否仍然与信号机连接,并根据需要执行代码。这是我的情况: if (hubConnection != null && hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected) { hubProxy.Invoke("hubMethod", hubParams); } else { hubConnection = new
if (hubConnection != null && hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
{
hubProxy.Invoke("hubMethod", hubParams);
}
else
{
hubConnection = new HubConnection(ConfigurationManager.AppSettings["signalRPath"].ToString());
hubProxy = hubConnection.CreateHubProxy("ChatHub");
hubConnection.Start().Wait();
hubProxy.Invoke("hubMethod", hubParams);
}
问题是,当我重新启动signalR服务器时,我的API继续从prev connection ID调用hubMethod,而不是使用signalR创建新的连接ID
如果我提供的信息不够,请让我知道 重新启动时,您是否将连接ID保留在服务器上的某个位置进行管理?@farrukhshubani我不这样认为。它基本上只是一个需要保持打开状态的连接,或者在服务器重新启动时重新连接。。