add code hub test

This commit is contained in:
Ryan Peters 2021-07-18 21:15:57 -04:00
parent 781c5cce27
commit 37b90af482
2 changed files with 19 additions and 4 deletions

View File

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BinaryDad.Coding.Hubs
{
public class CodeHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}

View File

@ -1,12 +1,9 @@
using BinaryDad.Coding.Hubs;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BinaryDad.Coding namespace BinaryDad.Coding
{ {
@ -23,6 +20,7 @@ namespace BinaryDad.Coding
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddRazorPages(); services.AddRazorPages();
services.AddSignalR();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -46,6 +44,7 @@ namespace BinaryDad.Coding
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapRazorPages(); endpoints.MapRazorPages();
endpoints.MapHub<CodeHub>("/codeHub");
}); });
} }
} }