SignalR core was demo with javascript client or Angular My case is using UWP to render the front-end. While Microsoft only tell how to Invoke the message from client to server, It's docs didn't show how to receive message [https://docs.microsoft.com/en-us/aspnet/core/signalr/dotnet-client?view=aspnetcore-2.2][1]
Here is my server:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSingleton<IInventoryServices, InventoryServices>();
services.AddSignalR();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseSignalR(route =>
{
route.MapHub<MessageHub>("/hub");
});
app.UseMvc();
}
}
this is the controller:
[Route("api/hub")]
[ApiController]
public class MessController : Controller
{
private IHubContext<MessageHub> _messhubContext;
public MessController(IHubContext<MessageHub> messhubContext)
{
_messhubContext = messhubContext;
}
public ActionResult Post()
{
_messhubContext.Clients.All.SendAsync("send", "Strypper", "Howdy");
System.Diagnostics.Debug.WriteLine("I'm here");
return Ok();
}
And here is the hub:
public class MessageHub : Hub
{
public Task Send(string user ,string message)
{
return Clients.All.SendAsync("Send", user, message);
}
}
My "PostMan" is messed up and I don't wanna discuss about it. Is there anyone here work with uwp framework could show me the way to receive the message from the server I made ?