diff --git a/samples/ChatApplication/ChatApplication.csproj b/samples/ChatApplication/ChatApplication.csproj
index c29eabc..c4f47fc 100644
--- a/samples/ChatApplication/ChatApplication.csproj
+++ b/samples/ChatApplication/ChatApplication.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/samples/ChatApplication/ChatHandler.cs b/samples/ChatApplication/ChatHandler.cs
index f818843..23aa6d3 100644
--- a/samples/ChatApplication/ChatHandler.cs
+++ b/samples/ChatApplication/ChatHandler.cs
@@ -1,48 +1,50 @@
-using System.Net.WebSockets;
+using Microsoft.AspNetCore.Http;
+using System.Net.WebSockets;
using System.Threading.Tasks;
using WebSocketManager;
using WebSocketManager.Common;
namespace ChatApplication
{
- public class ChatHandler : WebSocketHandler
+ public class ChatHandler : WebSocketHandler
+ {
+ public ChatHandler(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager)
{
- public ChatHandler(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager)
- {
- }
-
- public override async Task OnConnected(WebSocket socket)
- {
- await base.OnConnected(socket);
-
- var socketId = WebSocketConnectionManager.GetId(socket);
-
- var message = new Message()
- {
- MessageType = MessageType.Text,
- Data = $"{socketId} is now connected"
- };
-
- await SendMessageToAllAsync(message);
- }
-
- public async Task SendMessage(string socketId, string message)
- {
- await InvokeClientMethodToAllAsync("receiveMessage", socketId, message);
- }
-
- public override async Task OnDisconnected(WebSocket socket)
- {
- var socketId = WebSocketConnectionManager.GetId(socket);
-
- await base.OnDisconnected(socket);
-
- var message = new Message()
- {
- MessageType = MessageType.Text,
- Data = $"{socketId} disconnected"
- };
- await SendMessageToAllAsync(message);
- }
}
+
+ public override async Task OnConnected(WebSocket socket, HttpContext context)
+ {
+ await base.OnConnected(socket, context);
+
+ var socketId = WebSocketConnectionManager.GetId(socket);
+
+ var message = new Message()
+ {
+ MessageType = MessageType.Text,
+ Data = $"{socketId} is now connected"
+ };
+
+ await SendMessageToAllAsync(message, x => x.Query["age"] == "24");
+
+ }
+
+ public async Task SendMessage(string socketId, string message)
+ {
+ await InvokeClientMethodToAllAsync("receiveMessage", socketId, message);
+ }
+
+ public override async Task OnDisconnected(WebSocket socket)
+ {
+ var socketId = WebSocketConnectionManager.GetId(socket);
+
+ await base.OnDisconnected(socket);
+
+ var message = new Message()
+ {
+ MessageType = MessageType.Text,
+ Data = $"{socketId} disconnected"
+ };
+ await SendMessageToAllAsync(message, x => x.Query["age"] == "24");
+ }
+ }
}
diff --git a/samples/ChatApplication/Program.cs b/samples/ChatApplication/Program.cs
index 26d395f..5d91066 100755
--- a/samples/ChatApplication/Program.cs
+++ b/samples/ChatApplication/Program.cs
@@ -3,17 +3,18 @@
namespace ChatApplication
{
- public class Program
+ public class Program
+ {
+ public static void Main(string[] args)
{
- public static void Main(string[] args)
- {
- var host = new WebHostBuilder()
- .UseKestrel()
- .UseContentRoot(Directory.GetCurrentDirectory())
- .UseStartup()
- .Build();
+ var host = new WebHostBuilder()
+ .UseKestrel()
+ .UseContentRoot(Directory.GetCurrentDirectory())
+ .UseIISIntegration()
+ .UseStartup()
+ .Build();
- host.Run();
- }
+ host.Run();
}
+ }
}
diff --git a/samples/ChatApplication/wwwroot/client.html b/samples/ChatApplication/wwwroot/client.html
index 0b5c651..f21be09 100644
--- a/samples/ChatApplication/wwwroot/client.html
+++ b/samples/ChatApplication/wwwroot/client.html
@@ -18,7 +18,7 @@ This should be mapped to "/chat"