summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-27 17:43:56 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-27 17:43:56 +0200
commitf8018831b42fa9f534494babcd496f77e4709166 (patch)
tree85b833e83f6e0c65960671510f9af7cd81acfbca /DSACore
parent7b5e8b573302ba7896be7227aeac9a787685963b (diff)
added SignalR
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Hubs/ChatHub.cs16
-rw-r--r--DSACore/Startup.cs4
2 files changed, 20 insertions, 0 deletions
diff --git a/DSACore/Hubs/ChatHub.cs b/DSACore/Hubs/ChatHub.cs
new file mode 100644
index 0000000..44d86e1
--- /dev/null
+++ b/DSACore/Hubs/ChatHub.cs
@@ -0,0 +1,16 @@
+using Microsoft.AspNetCore.SignalR;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Hubs
+{
+ public class ChatHub : Hub
+ {
+ public async Task SendMessage(string user, string message)
+ {
+ await Clients.All.SendAsync("ReciveMessage", user, message);
+ }
+ }
+}
diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs
index 2d0c2a3..1745ea4 100644
--- a/DSACore/Startup.cs
+++ b/DSACore/Startup.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using DSACore.Hubs;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
@@ -26,6 +27,8 @@ namespace DSACore
public void ConfigureServices(IServiceCollection services)
{
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.
@@ -41,6 +44,7 @@ namespace DSACore
}
app.UseHttpsRedirection();
+ app.UseSignalR(routes => { routes.MapHub<ChatHub>("/chatHub"); });
app.UseMvc();
}
}