Commit 0c8e107a authored by Clint Mourlevat's avatar Clint Mourlevat

Adding SignalR

parent dcd92c50
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
namespace Stratis.Guru.Hubs
{
public class UpdateHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Stratis.Guru.Hubs;
using Stratis.Guru.Modules;
using Stratis.Guru.Services;
......@@ -48,6 +49,8 @@ namespace Stratis.Guru
services.AddHostedService<VanityService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSignalR();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......@@ -76,6 +79,11 @@ namespace Stratis.Guru
RequestPath = "/npm"
});
app.UseSignalR(routes =>
{
routes.MapHub<UpdateHub>("/update");
});
app.UseMvc(routes =>
{
routes.MapRoute(
......
......@@ -8,6 +8,7 @@
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.4" />
<PackageReference Include="NStratis" Version="4.0.0.34" />
<PackageReference Include="QRCoder" Version="1.3.3" />
<PackageReference Include="RestSharp" Version="106.5.4" />
......
......@@ -28,6 +28,14 @@
$(document).ready(function() {
var stratisPrice = @Model.UsdPrice;
var signalr = new signalR.HubConnectionBuilder().withUrl("/update").build();
signalr.on("ReceiveMessage", function (user, message) {
alert("ok");
});
signalr.start();
$(".click-edit").click(function() {
alert("ok");
})
......
......@@ -4,6 +4,11 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@aspnet/signalr": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@aspnet/signalr/-/signalr-1.0.4.tgz",
"integrity": "sha512-q7HMlTZPkZCa/0UclsXvEyqNirpjRfRuwhjEeADD1i6pqe0Yx5OwuCO7+Xsc6MNKR8vE1C9MyxnSj0SecvUbTA=="
},
"bootstrap": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.1.3.tgz",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment