The input value is posted twice as I use myHub.Invoke(Of String)("Chatter", Input)
two places after declaring and in else statement.
I don't know whether I can replace the .continuewith
block in the below code.
Sub Main()
Dim connection = New HubConnection("http://localhost:8080")
Dim myHub = connection.CreateHubProxy("myHub")
connection.Start().Wait()
Console.ForegroundColor = ConsoleColor.Yellow
Dim Input As String = Console.ReadLine
myHub.Invoke(Of String)("Chatter", Input) _
.ContinueWith(
Sub(task)
If task.IsFaulted Then
Console.WriteLine("Could not Invoke the server method Chatter: {0}", _
task.Exception.GetBaseException())
Else
myHub.Invoke(Of String)("Chatter", Input)
Console.WriteLine("Enter a value to send to the Client. Enter 'Exit' to quit")
Input = Console.ReadLine()
Console.WriteLine("Success calling chatter method")
End If
End Sub)
myHub.On(Of String)("addMessage", _
Sub(param)
Console.WriteLine("Client receiving value from server: {0}", param.ToString())
End Sub)
Console.ReadLine()
End Sub
After replacing continuewith block the client is not receiving the value from server.
Sub Main()
Dim connection = New HubConnection("http://localhost:8080")
Dim myHub = connection.CreateHubProxy("myHub")
connection.Start().Wait()
Console.ForegroundColor = ConsoleColor.Yellow
Dim Input As String = Console.ReadLine
myHub.Invoke(Of String)("Chatter", Input) _
.ContinueWith(
Sub(task)
If task.IsFaulted Then
Console.WriteLine("Could not Invoke the server method Chatter: {0}", _
task.Exception.GetBaseException())
Else
myHub.Invoke(Of String)("Chatter", Input)
Console.WriteLine("Enter a value to send to the Client. Enter 'Exit' to quit")
Input = Console.ReadLine()
Console.WriteLine("Success calling chatter method")
End If
End Sub)
myHub.On(Of String)("addMessage", _
Sub(param)
Console.WriteLine("Client receiving value from server: {0}", param.ToString())
End Sub)
Console.ReadLine()
End Sub