1+ using Microsoft . AspNetCore . Http ;
2+
13namespace CodeBehind
24{
35 public abstract class CodeBehindModel
@@ -6,6 +8,7 @@ public abstract class CodeBehindModel
68 public string WebFormsValue = "" ;
79 public bool IgnoreView = false ;
810 public bool ? IgnoreLayout = null ;
11+ public string ? WebSocketId = null ;
912 public HtmlData . NameValueCollection ViewData = new HtmlData . NameValueCollection ( ) ;
1013 public ValueCollectionLock Section = new ValueCollectionLock ( ) ;
1114 public string DownloadFilePath { get ; private set ; } = "" ;
@@ -67,5 +70,61 @@ public void Download(string FilePath)
6770 {
6871 DownloadFilePath = FilePath ;
6972 }
73+
74+ public void SetWebSocketId ( string Id )
75+ {
76+ WebSocketId = Id ;
77+ }
78+
79+ // WebSockets Broadcast
80+ public void Broadcast ( HttpContext context , string Message , bool IgnoreThis = false )
81+ {
82+ CodeBehindMiddlewareExtensions . WebSocketsBroadcast ( context , Message , "" , "" , "" , IgnoreThis ) ;
83+ }
84+
85+ public async void BroadcastAsync ( HttpContext context , string Message , bool IgnoreThis = false )
86+ {
87+ await CodeBehindMiddlewareExtensions . WebSocketsBroadcastAsync ( context , Message , "" , "" , "" , IgnoreThis ) ;
88+ }
89+
90+ public void Broadcast ( HttpContext context , string Message , string RoleName , string Id , string ClientId , bool IgnoreThis = false )
91+ {
92+ CodeBehindMiddlewareExtensions . WebSocketsBroadcast ( context , Message , RoleName , Id , ClientId , IgnoreThis ) ;
93+ }
94+
95+ public async void BroadcastAsync ( HttpContext context , string Message , string RoleName , string Id , string ClientId , bool IgnoreThis = false )
96+ {
97+ await CodeBehindMiddlewareExtensions . WebSocketsBroadcastAsync ( context , Message , RoleName , Id , ClientId , IgnoreThis ) ;
98+ }
99+
100+ public void BroadcastForRole ( HttpContext context , string Message , string RoleName , bool IgnoreThis = false )
101+ {
102+ CodeBehindMiddlewareExtensions . WebSocketsBroadcast ( context , Message , RoleName , "" , "" , IgnoreThis ) ;
103+ }
104+
105+ public async void BroadcastForRoleAsync ( HttpContext context , string Message , string RoleName , bool IgnoreThis = false )
106+ {
107+ await CodeBehindMiddlewareExtensions . WebSocketsBroadcastAsync ( context , Message , RoleName , "" , "" , IgnoreThis ) ;
108+ }
109+
110+ public void BroadcastForWebSocketId ( HttpContext context , string Message , string Id , bool IgnoreThis = false )
111+ {
112+ CodeBehindMiddlewareExtensions . WebSocketsBroadcast ( context , Message , "" , Id , "" , IgnoreThis ) ;
113+ }
114+
115+ public async void BroadcastForWebSocketIdAsync ( HttpContext context , string Message , string Id , bool IgnoreThis = false )
116+ {
117+ await CodeBehindMiddlewareExtensions . WebSocketsBroadcastAsync ( context , Message , "" , Id , "" , IgnoreThis ) ;
118+ }
119+
120+ public void BroadcastForClientId ( HttpContext context , string Message , string ClientId , bool IgnoreThis = false )
121+ {
122+ CodeBehindMiddlewareExtensions . WebSocketsBroadcast ( context , Message , "" , "" , ClientId , IgnoreThis ) ;
123+ }
124+
125+ public async void BroadcastForClientIdAsync ( HttpContext context , string Message , string ClientId , bool IgnoreThis = false )
126+ {
127+ await CodeBehindMiddlewareExtensions . WebSocketsBroadcastAsync ( context , Message , "" , "" , ClientId , IgnoreThis ) ;
128+ }
70129 }
71130}
0 commit comments