// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapHub <SignalRController>("/SignalR"); }); var connection = new HubConnectionBuilder() .WithUrl("http://localhost:7778/SignalR") .AddJsonProtocol() .Build(); Task.Run(async() => { var p1 = new PingClass { Type = PingType.Ping, Message = "Hello" }; await connection.StartAsync(); await connection.InvokeAsync("Ping", p1.Type, p1.Message); var p2 = await connection.InvokeAsync <PingClass>("PingWithClass", p1); Console.WriteLine($"{p1} == {p2}: {p1 == p2}"); }); }
public PingClass PingWithClass(PingClass p) { Console.WriteLine($"Ping type {p.Type}: {p.Message}"); return(p); }