2
我想在.NET客戶端中使用SignalR。我能夠成功連接,但在嘗試訂閱事件時沒有任何反應。我無法接收從服務器發送的消息。我對這個領域很陌生,所以我不確定我是否在我的代碼中丟失了某些東西或某些東西是錯誤的。.NET SignalR客戶端無法訂閱服務器事件
var hubConnection = new HubConnection(<url>);
// Hub name from dev code
var proxy = hubConnection.CreateHubProxy("pidHub");
// Subscribing to all the events
proxy.On("SendTransactionUpdate",() => Logger.LogInformation("SendTransactionUpdate ************************"));
proxy.On("SendMessage",() => Logger.LogInformation("SendMessage ************************"));
proxy.On("UpdateStatus",() => Logger.LogInformation("UpdateStatus ************************"));
proxy.On("TransactionUpdate",() => Logger.LogInformation("TransactionUpdate ************************"));
// This block executes fine
hubConnection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
Logger.LogInformation("There was an error opening the connection: {0}" + task.Exception.GetBaseException());
}
else
{
Logger.LogInformation("Connected. *********");
}
}).Wait();
// Call Provision GUID API and returns a valid GUID
<call API>
// Downloads EXE on machine
<download EXE code>
// Run EXE with -d option
// EXE uploads results back to the server and server returns some messages through SignalR
// I want to capture these messages
<execute EXE on machine>