@@ -8,13 +8,13 @@ public class WebsocketHandlerBuilder : IHandlerBuilder<WebsocketHandlerBuilder>
88
99 private readonly List < string > _SupportedProtocols = [ ] ;
1010
11- private Action < IWebsocketConnection > ? _OnOpen ;
12- private Action < IWebsocketConnection > ? _OnClose ;
13- private Action < IWebsocketConnection , string > ? _OnMessage ;
14- private Action < IWebsocketConnection , byte [ ] > ? _OnBinary ;
15- private Action < IWebsocketConnection , byte [ ] > ? _OnPing ;
16- private Action < IWebsocketConnection , byte [ ] > ? _OnPong ;
17- private Action < IWebsocketConnection , Exception > ? _OnError ;
11+ private Func < IWebsocketConnection , Task > ? _OnOpen ;
12+ private Func < IWebsocketConnection , Task > ? _OnClose ;
13+ private Func < IWebsocketConnection , string , Task > ? _OnMessage ;
14+ private Func < IWebsocketConnection , byte [ ] , Task > ? _OnBinary ;
15+ private Func < IWebsocketConnection , byte [ ] , Task > ? _OnPing ;
16+ private Func < IWebsocketConnection , byte [ ] , Task > ? _OnPong ;
17+ private Func < IWebsocketConnection , Exception , Task > ? _OnError ;
1818
1919 #region Functionality
2020
@@ -38,7 +38,7 @@ public WebsocketHandlerBuilder Protocol(string supportedProtocol)
3838 /// Will be executed if a new websocket client connected.
3939 /// </summary>
4040 /// <param name="handler">The method to be executed</param>
41- public WebsocketHandlerBuilder OnOpen ( Action < IWebsocketConnection > handler )
41+ public WebsocketHandlerBuilder OnOpen ( Func < IWebsocketConnection , Task > handler )
4242 {
4343 _OnOpen = handler ;
4444 return this ;
@@ -48,7 +48,7 @@ public WebsocketHandlerBuilder OnOpen(Action<IWebsocketConnection> handler)
4848 /// Will be executed if a websocket client disconnects.
4949 /// </summary>
5050 /// <param name="handler">The method to be executed</param>
51- public WebsocketHandlerBuilder OnClose ( Action < IWebsocketConnection > handler )
51+ public WebsocketHandlerBuilder OnClose ( Func < IWebsocketConnection , Task > handler )
5252 {
5353 _OnClose = handler ;
5454 return this ;
@@ -58,7 +58,7 @@ public WebsocketHandlerBuilder OnClose(Action<IWebsocketConnection> handler)
5858 /// Will be executed if a string message has been received from the client.
5959 /// </summary>
6060 /// <param name="handler">The method to be executed</param>
61- public WebsocketHandlerBuilder OnMessage ( Action < IWebsocketConnection , string > handler )
61+ public WebsocketHandlerBuilder OnMessage ( Func < IWebsocketConnection , string , Task > handler )
6262 {
6363 _OnMessage = handler ;
6464 return this ;
@@ -68,7 +68,7 @@ public WebsocketHandlerBuilder OnMessage(Action<IWebsocketConnection, string> ha
6868 /// Will be executed if a binary message has been received from the client.
6969 /// </summary>
7070 /// <param name="handler">The method to be executed</param>
71- public WebsocketHandlerBuilder OnBinary ( Action < IWebsocketConnection , byte [ ] > handler )
71+ public WebsocketHandlerBuilder OnBinary ( Func < IWebsocketConnection , byte [ ] , Task > handler )
7272 {
7373 _OnBinary = handler ;
7474 return this ;
@@ -78,7 +78,7 @@ public WebsocketHandlerBuilder OnBinary(Action<IWebsocketConnection, byte[]> han
7878 /// Will be executed if the client sends a ping request.
7979 /// </summary>
8080 /// <param name="handler">The method to be executed</param>
81- public WebsocketHandlerBuilder OnPing ( Action < IWebsocketConnection , byte [ ] > handler )
81+ public WebsocketHandlerBuilder OnPing ( Func < IWebsocketConnection , byte [ ] , Task > handler )
8282 {
8383 _OnPing = handler ;
8484 return this ;
@@ -88,7 +88,7 @@ public WebsocketHandlerBuilder OnPing(Action<IWebsocketConnection, byte[]> handl
8888 /// Will be executed if the client sends a pong request.
8989 /// </summary>
9090 /// <param name="handler">The method to be executed</param>
91- public WebsocketHandlerBuilder OnPong ( Action < IWebsocketConnection , byte [ ] > handler )
91+ public WebsocketHandlerBuilder OnPong ( Func < IWebsocketConnection , byte [ ] , Task > handler )
9292 {
9393 _OnPong = handler ;
9494 return this ;
@@ -98,7 +98,7 @@ public WebsocketHandlerBuilder OnPong(Action<IWebsocketConnection, byte[]> handl
9898 /// Will be executed if there is some client connection error.
9999 /// </summary>
100100 /// <param name="handler">The method to be executed</param>
101- public WebsocketHandlerBuilder OnError ( Action < IWebsocketConnection , Exception > handler )
101+ public WebsocketHandlerBuilder OnError ( Func < IWebsocketConnection , Exception , Task > handler )
102102 {
103103 _OnError = handler ;
104104 return this ;
0 commit comments