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; ...@@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
using Stratis.Guru.Hubs;
using Stratis.Guru.Modules; using Stratis.Guru.Modules;
using Stratis.Guru.Services; using Stratis.Guru.Services;
...@@ -48,6 +49,8 @@ namespace Stratis.Guru ...@@ -48,6 +49,8 @@ namespace Stratis.Guru
services.AddHostedService<VanityService>(); services.AddHostedService<VanityService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 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. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...@@ -76,6 +79,11 @@ namespace Stratis.Guru ...@@ -76,6 +79,11 @@ namespace Stratis.Guru
RequestPath = "/npm" RequestPath = "/npm"
}); });
app.UseSignalR(routes =>
{
routes.MapHub<UpdateHub>("/update");
});
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" /> <PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /> <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="NStratis" Version="4.0.0.34" />
<PackageReference Include="QRCoder" Version="1.3.3" /> <PackageReference Include="QRCoder" Version="1.3.3" />
<PackageReference Include="RestSharp" Version="106.5.4" /> <PackageReference Include="RestSharp" Version="106.5.4" />
......
...@@ -28,6 +28,14 @@ ...@@ -28,6 +28,14 @@
$(document).ready(function() { $(document).ready(function() {
var stratisPrice = @Model.UsdPrice; 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() { $(".click-edit").click(function() {
alert("ok"); alert("ok");
}) })
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "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": { "bootstrap": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.1.3.tgz", "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