4using System.Threading.Tasks;
66 : base(
"/ClientEvents")
98 if (
string.IsNullOrEmpty(Request.
SubPath))
104 string Id = Request.
SubPath[1..];
110 lock (requestsByContentID)
112 if (requestsByContentID.TryGetValue(Id, out ContentQueue Queue))
114 if (Queue.Content is
null)
116 Queue.Response = Response;
121 ConstantBuffer = Queue.ConstantBuffer;
122 Content = Queue.Content;
123 ContentType = Queue.ContentType;
128 Queue.ConstantBuffer =
false;
129 Queue.Content =
null;
130 Queue.ContentType =
null;
133 requestsByContentID.Remove(Id);
137 requestsByContentID[Id] =
new ContentQueue(Id)
148 Response.
SetHeader(
"X-More", More ?
"1" :
"0");
149 Response.ContentType = ContentType;
150 await Response.
Write(ConstantBuffer, Content, 0, Content.Length);
177 string TabID = Request.
Header[
"X-TabID"];
178 if (
string.IsNullOrEmpty(TabID))
184 TabQueue Queue = Register(Request, Response,
null, Location, TabID);
185 StringBuilder Json =
null;
191 if (!await Queue.SyncObj.TryBeginWrite(10000))
199 if (!(Queue.Queue.First is
null))
201 foreach (
string Event in Queue.Queue)
204 Json =
new StringBuilder(
"[");
212 Queue.Response =
null;
215 Queue.Response = Response;
219 await Queue.SyncObj.EndWrite();
224 timeoutByTabID.Remove(TabID);
227 await Response.
Write(Json.ToString());
232 timeoutByTabID[TabID] = Queue;
237 Uri Uri =
new Uri(Location);
238 string Resource = Uri.LocalPath;
239 (string, string, string)[] Query =
null;
243 if (!
string.IsNullOrEmpty(Uri.Query))
246 if (s.StartsWith(
"?"))
249 string[] Parts = s.Split(
'&');
250 Query =
new (string, string, string)[Parts.Length];
253 foreach (
string Part in Parts)
255 i = Part.IndexOf(
'=');
257 Query[j++] = (Part,
string.Empty,
string.Empty);
260 string s2 = Part[(i + 1)..];
261 Query[j++] = (Part[..i], s2,
System.
Net.WebUtility.UrlDecode(s2));
266 if (eventsByTabID.TryGetValue(TabID, out TabQueue Queue) &&
267 !
string.IsNullOrEmpty(Queue.SessionID) &&
268 !(Queue.SyncObj is
null))
270 Queue.WebSocket = Socket;
278 TabQueue Queue2 =
new TabQueue(TabID,
HttpSessionID, Session,
false)
285 if (!(Queue is
null))
287 while (!(Queue.Queue.First is
null))
289 Queue2.Queue.AddLast(Queue.Queue.First.Value);
290 Queue.Queue.RemoveFirst();
295 eventsByTabID[TabID] = Queue;
298 lock (locationByTabID)
300 if (!locationByTabID.TryGetValue(TabID, out s) || s != Resource)
301 locationByTabID[TabID] = Resource;
304 lock (tabIdsByLocation)
306 if (!tabIdsByLocation.TryGetValue(Resource, out Dictionary<
string, (
string,
string,
string)[]> TabIds))
308 TabIds =
new Dictionary<string, (string, string, string)[]>();
309 tabIdsByLocation[Resource] = TabIds;
312 TabIds[TabID] = Query;
318 if (!(Session is
null) &&
320 !((UserObject = UserId(UserVariable.ValueObject)) is
null))
324 if (!usersByTabID.TryGetValue(TabID, out
object Obj2) || !Obj2.Equals(UserObject))
325 usersByTabID[TabID] = UserObject;
328 UserType = UserObject.GetType();
332 if (!tabIdsByUser.TryGetValue(UserType, out Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>> UserObjects))
334 UserObjects =
new Dictionary<object, Dictionary<string, (string, string, string)[]>>();
335 tabIdsByUser[UserType] = UserObjects;
338 if (!UserObjects.TryGetValue(UserObject, out Dictionary<
string, (
string,
string,
string)[]> TabIds))
340 TabIds =
new Dictionary<string, (string, string, string)[]>();
341 UserObjects[UserObject] = TabIds;
344 TabIds[TabID] = Query;
351 if (!usersByTabID.TryGetValue(TabID, out UserObject))
355 if (!(UserObject is
null))
357 UserType = UserObject.GetType();
361 if (tabIdsByUser.TryGetValue(UserType, out Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>> UserObjects))
363 if (UserObjects.Remove(UserObject) && UserObjects.Count == 0)
364 tabIdsByUser.Remove(UserType);
373 private static object UserId(
object User)
375 if (User is
IUser User2)
376 return User2.UserName;
379 if (GenObj.TryGetFieldValue(
"UserName", out
object UserName))
382 return GenObj.ObjectId;
384 else if (User is Dictionary<string, IElement> ScriptObj)
386 if (ScriptObj.TryGetValue(
"UserName", out
IElement UserName))
387 return UserName.AssociatedObjectValue;
391 else if (User is Dictionary<string, object> JsonObj)
393 if (JsonObj.TryGetValue(
"UserName", out
object UserName))
402 internal static async Task RegisterWebSocket(
WebSocket Socket,
string Location,
string TabID)
405 LinkedList<string> ToSend =
null;
407 if (!await Queue.SyncObj.TryBeginWrite(10000))
412 if (!(Queue.Queue.First is
null))
414 ToSend =
new LinkedList<string>();
416 foreach (
string s2
in Queue.Queue)
424 await Queue.SyncObj.EndWrite();
427 if (!(ToSend is
null))
429 foreach (
string s2
in ToSend)
430 await Socket.
Send(s2, 4096);
434 internal static void Ping(
string TabID)
436 if (eventsByTabID.TryGetValue(TabID, out TabQueue TabQueue))
440 internal static async Task UnregisterWebSocket(
WebSocket Socket,
string Location,
string TabID)
442 if (eventsByTabID.TryGetValue(TabID, out TabQueue Queue) && Queue.WebSocket == Socket)
444 if (!await Queue.SyncObj.TryBeginWrite(10000))
449 Queue.WebSocket =
null;
453 await Queue.SyncObj.EndWrite();
456 if (Queue.KeepAliveUntil > DateTime.Now)
460 Uri Uri =
new Uri(Location);
461 Remove(TabID, Uri.LocalPath);
472 if (!eventsByTabID.TryGetValue(TabID, out TabQueue Queue))
475 eventsByTabID[TabID] = Queue;
478 DateTime Now = DateTime.Now;
482 DateTime CurrentKeepAliveTime = Queue.KeepAliveUntil;
484 if (CurrentKeepAliveTime < KeepAliveUntil)
486 Queue.KeepAliveUntil = KeepAliveUntil;
488 if (CurrentKeepAliveTime == DateTime.MinValue)
496 if (State is
string TabID &&
497 eventsByTabID.TryGetValue(TabID, out TabQueue Queue))
499 DateTime Now = DateTime.Now;
501 if (Queue.KeepAliveUntil < Now)
502 Queue.KeepAliveUntil = DateTime.MinValue;
511 private static readonly Dictionary<string, string> locationByTabID =
new Dictionary<string, string>();
512 private static readonly Dictionary<string, object> usersByTabID =
new Dictionary<string, object>();
513 private static readonly Dictionary<string, Dictionary<string, (string, string, string)[]>> tabIdsByLocation =
514 new Dictionary<
string, Dictionary<
string, (
string,
string,
string)[]>>(StringComparer.OrdinalIgnoreCase);
515 private static readonly Dictionary<Type, Dictionary<object, Dictionary<string, (string, string, string)[]>>> tabIdsByUser =
516 new Dictionary<Type, Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>>>();
521 Result.Removed += TimeoutCacheItem_Removed;
531 if (!(Response is
null))
535 e.Value.Response =
null;
537 await Response.
Write(
"[{\"type\":\"NOP\"}]");
555 Result.Removed += QueueCacheItem_Removed;
561 TabQueue Queue = e.
Value;
562 string TabID = Queue.TabID;
565 await Queue.DisposeAsync();
568 private static void Remove(
string TabID,
string Resource)
573 lock (locationByTabID)
575 if (locationByTabID.TryGetValue(TabID, out Location) && (Resource is
null || Location == Resource))
576 locationByTabID.Remove(TabID);
581 if (!(Location is
null))
583 lock (tabIdsByLocation)
585 if (tabIdsByLocation.TryGetValue(Location, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
587 if (TabIDs.Remove(TabID) && TabIDs.Count == 0)
588 tabIdsByLocation.Remove(Location);
595 if (usersByTabID.TryGetValue(TabID, out User))
596 usersByTabID.Remove(TabID);
603 Type UserType = User.GetType();
607 if (tabIdsByUser.TryGetValue(UserType, out Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>> UserObjects) &&
608 UserObjects.TryGetValue(User, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
610 if (TabIDs.Remove(TabID) && TabIDs.Count == 0 &&
611 UserObjects.Remove(User) && UserObjects.Count == 0)
613 tabIdsByUser.Remove(UserType);
623 Result.Removed += ContentCacheItem_Removed;
635 if (!(Response is
null))
638 await Response.
Write(
"Request took too long to complete.");
658 bool ConstantBuffer,
byte[] Result)
673 bool ConstantBuffer,
byte[] Result,
bool More)
679 lock (requestsByContentID)
681 if (requestsByContentID.TryGetValue(Id, out ContentQueue Queue))
683 if (Queue.Response is
null)
685 Queue.ContentType = ContentType;
686 Queue.ConstantBuffer = ConstantBuffer;
687 Queue.Content = Result;
692 Response = Queue.Response;
695 Queue.Response =
null;
697 requestsByContentID.Remove(Id);
701 Queue =
new ContentQueue(Id)
703 ContentType = ContentType,
704 ConstantBuffer = ConstantBuffer,
709 requestsByContentID[Id] = Queue;
714 Response.
SetHeader(
"X-More", More ?
"1" :
"0");
715 Response.ContentType = ContentType;
716 await Response.
Write(ConstantBuffer, Result, 0, Result.Length);
733 lock (tabIdsByLocation)
735 Result =
new string[tabIdsByLocation.Count];
736 tabIdsByLocation.Keys.CopyTo(Result, 0);
748 List<object> Result =
new List<object>();
752 foreach (KeyValuePair<Type, Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>>> P in tabIdsByUser)
753 Result.AddRange(P.Value.Keys);
756 return Result.ToArray();
776 public static string[]
GetTabIDsForLocation(
string Location,
string QueryParameter1,
string QueryParameterValue1)
778 return GetTabIDsForLocation(Location,
new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1));
790 public static string[]
GetTabIDsForLocation(
string Location,
string QueryParameter1,
string QueryParameterValue1,
791 string QueryParameter2,
string QueryParameterValue2)
794 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1),
795 new KeyValuePair<string, string>(QueryParameter2, QueryParameterValue2));
804 public static string[]
GetTabIDsForLocation(
string Location, params KeyValuePair<string, string>[] QueryFilter)
818 string QueryParameter1,
string QueryParameterValue1)
820 return GetTabIDsForLocation(Location, IgnoreCase,
new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1));
834 string QueryParameter1,
string QueryParameterValue1,
835 string QueryParameter2,
string QueryParameterValue2)
838 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1),
839 new KeyValuePair<string, string>(QueryParameter2, QueryParameterValue2));
849 public static string[]
GetTabIDsForLocation(
string Location,
bool IgnoreCase, params KeyValuePair<string, string>[] QueryFilter)
851 lock (tabIdsByLocation)
853 if (tabIdsByLocation.TryGetValue(Location, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
854 return ProcessQueryFilterLocked(TabIDs, QueryFilter, IgnoreCase);
857 if (eventsByTabID.TryGetValue(Location, out TabQueue Queue))
859 return ProcessQueryFilterLocked(
new Dictionary<
string, (
string,
string,
string)[]>()
861 { Location, Queue.Query }
862 }, QueryFilter, IgnoreCase);
865 return Array.Empty<
string>();
875 return GetTabIDsForUser(User,
null,
false, Array.Empty<KeyValuePair<string, string>>());
884 public static string[]
GetTabIDsForUser(
object User, params KeyValuePair<string, string>[] QueryFilter)
898 string QueryParameter1,
string QueryParameterValue1)
900 return GetTabIDsForUser(User, IgnoreCase,
new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1));
914 string QueryParameter1,
string QueryParameterValue1,
915 string QueryParameter2,
string QueryParameterValue2)
918 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1),
919 new KeyValuePair<string, string>(QueryParameter2, QueryParameterValue2));
929 public static string[]
GetTabIDsForUser(
object User,
bool IgnoreCase, params KeyValuePair<string, string>[] QueryFilter)
942 return GetTabIDsForUser(User, Location, Array.Empty<KeyValuePair<string, string>>());
954 string QueryParameter1,
string QueryParameterValue1)
957 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1));
971 string QueryParameter1,
string QueryParameterValue1,
972 string QueryParameter2,
string QueryParameterValue2)
975 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1),
976 new KeyValuePair<string, string>(QueryParameter2, QueryParameterValue2));
986 public static string[]
GetTabIDsForUser(
object User,
string Location, params KeyValuePair<string, string>[] QueryFilter)
1001 string QueryParameter1,
string QueryParameterValue1)
1004 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1));
1019 string QueryParameter1,
string QueryParameterValue1,
1020 string QueryParameter2,
string QueryParameterValue2)
1023 new KeyValuePair<string, string>(QueryParameter1, QueryParameterValue1),
1024 new KeyValuePair<string, string>(QueryParameter2, QueryParameterValue2));
1035 public static string[]
GetTabIDsForUser(
object User,
string Location,
bool IgnoreCase, params KeyValuePair<string, string>[] QueryFilter)
1037 User = UserId(User);
1038 Type T = User.GetType();
1043 if (tabIdsByUser.TryGetValue(T, out Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>> UserObjects) &&
1044 UserObjects.TryGetValue(User, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
1046 Result = ProcessQueryFilterLocked(TabIDs, QueryFilter, IgnoreCase);
1049 return Array.Empty<
string>();
1052 if (
string.IsNullOrEmpty(Location))
1055 List<string> Result2 =
new List<string>();
1057 lock (tabIdsByLocation)
1059 if (tabIdsByLocation.TryGetValue(Location, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
1061 foreach (
string TabID
in Result)
1063 if (TabIDs.ContainsKey(TabID))
1069 return Result2.ToArray();
1072 private static string[] ProcessQueryFilterLocked(Dictionary<
string, (
string,
string,
string)[]> TabIDs,
1073 KeyValuePair<string, string>[] QueryFilter,
bool IgnoreCase)
1077 if (QueryFilter is
null || QueryFilter.Length == 0)
1079 Result =
new string[TabIDs.Count];
1080 TabIDs.Keys.CopyTo(Result, 0);
1084 List<string> Match =
new List<string>();
1088 foreach (KeyValuePair<
string, (
string,
string,
string)[]> P in TabIDs)
1092 foreach (KeyValuePair<string, string> Q
in QueryFilter)
1094 if (Q.Value is
null)
1098 if (!(P.Value is
null))
1100 foreach ((
string,
string,
string) Q2 in P.Value)
1102 if (Q2.Item1 == Q.Key)
1120 if (!(P.Value is
null))
1122 foreach ((
string,
string,
string) Q2 in P.Value)
1124 if (Q2.Item1 == Q.Key &&
1125 (
string.Compare(Q2.Item2, Q.Value, IgnoreCase) == 0 ||
1126 string.Compare(Q2.Item3, Q.Value, IgnoreCase) == 0))
1146 Result = Match.ToArray();
1159 switch (Locations.Length)
1162 return Array.Empty<
string>();
1168 Dictionary<string, bool> Result =
new Dictionary<string, bool>();
1170 lock (tabIdsByLocation)
1172 foreach (
string Location
in Locations)
1174 if (tabIdsByLocation.TryGetValue(Location, out Dictionary<
string, (
string,
string,
string)[]> TabIDs))
1176 foreach (
string TabID
in TabIDs.Keys)
1177 Result[TabID] =
true;
1182 string[] Result2 =
new string[Result.Count];
1183 Result.Keys.CopyTo(Result2, 0);
1197 lock (locationByTabID)
1199 Result =
new string[locationByTabID.Count];
1200 locationByTabID.Keys.CopyTo(Result, 0);
1212 Dictionary<string, bool> Result =
new Dictionary<string, bool>();
1216 foreach (Dictionary<
object, Dictionary<
string, (
string,
string,
string)[]>> P in tabIdsByUser.Values)
1218 foreach (Dictionary<
string, (
string,
string,
string)[]> P2 in P.Values)
1220 foreach (
string TabID
in P2.Keys)
1221 Result[TabID] =
true;
1226 string[] Result2 =
new string[Result.Count];
1227 Result.Keys.CopyTo(Result2, 0);
1238 if (eventsByTabID.TryGetValue(TabID, out TabQueue Queue))
1255 this.TabID = Queue.
TabID;
1256 this.SessionID = Queue.SessionID;
1257 this.Session = Queue.Session;
1258 this.Uri = Queue.Uri;
1260 this.Query =
new Dictionary<string, string>();
1262 if (!(Queue.Query is
null))
1264 foreach ((
string,
string,
string) Rec in Queue.Query)
1265 this.
Query[Rec.Item1] = Rec.Item3;
1292 public Dictionary<string, string>
Query {
get; }
1299 public string TabID;
1300 public string SessionID;
1303 public LinkedList<string> Queue =
new LinkedList<string>();
1305 public Uri Uri =
null;
1306 public DateTime KeepAliveUntil = DateTime.MinValue;
1307 public (string, string, string)[] Query =
null;
1308 private bool disposeSession;
1310 public TabQueue(
string ID,
string SessionID,
SessionVariables Session,
bool DisposeSession)
1314 this.SessionID = SessionID;
1315 this.Session = Session;
1316 this.disposeSession = DisposeSession;
1321 get => this.webSocket;
1324 if (this.webSocket != value)
1326 if (!(this.webSocket is
null))
1327 this.webSocket.Heartbeat -= this.Ping;
1329 this.webSocket = value;
1331 if (!(this.webSocket is
null))
1332 this.webSocket.Heartbeat += this.Ping;
1337 [Obsolete(
"Use DisposeAsync instead.")]
1338 public void Dispose()
1340 this.DisposeAsync().Wait();
1343 public async Task DisposeAsync()
1345 this.WebSocket =
null;
1350 this.SyncObj =
null;
1352 if (this.disposeSession)
1355 this.Session =
null;
1358 this.Queue?.Clear();
1363 eventsByTabID.Ping(this.TabID);
1365 return Task.CompletedTask;
1370 if (!
string.IsNullOrEmpty(this.SessionID))
1371 Gateway.HttpServer?.GetSession(this.SessionID,
false);
1375 private class ContentQueue
1377 public string ContentID;
1380 public bool ConstantBuffer;
1381 public byte[] Content =
null;
1382 public bool More =
false;
1384 public ContentQueue(
string ID)
1386 this.ContentID = ID;
1397 public static Task<int>
PushEvent(
string[] TabIDs,
string Type,
object Data)
1399 if (Data is
string s)
1400 return PushEvent(TabIDs, Type, s,
false,
null,
null);
1404 return PushEvent(TabIDs, Type, s,
true,
null,
null);
1415 public static Task<int>
PushEvent(
string[] TabIDs,
string Type,
string Data)
1417 return PushEvent(TabIDs, Type, Data,
false,
null,
null);
1428 public static Task<int>
PushEvent(
string[] TabIDs,
string Type,
string Data,
bool DataIsJson)
1430 return PushEvent(TabIDs, Type, Data, DataIsJson,
null,
null);
1445 public static async Task<int>
PushEvent(
string[] TabIDs,
string Type,
string Data,
bool DataIsJson,
string UserVariable, params
string[] Privileges)
1451 StringBuilder Json =
new StringBuilder();
1453 Json.Append(
"{\"type\":\"");
1455 Json.Append(
"\",\"data\":");
1468 string s = Json.ToString();
1470 TabIDs ??= eventsByTabID.GetKeys();
1472 foreach (
string TabID
in TabIDs)
1474 if (!(TabID is
null) && eventsByTabID.TryGetValue(TabID, out TabQueue Queue))
1476 if (!
string.IsNullOrEmpty(UserVariable))
1478 if (!Queue.Session.TryGetVariable(UserVariable, out
Variable v) ||
1479 !(v.ValueObject is
IUser User))
1484 if (!(Privileges is
null))
1486 bool HasPrivileges =
true;
1488 foreach (
string Privilege
in Privileges)
1490 if (!User.HasPrivilege(Privilege))
1492 HasPrivileges =
false;
1502 if (await Queue.SyncObj.TryBeginWrite(10000))
1506 if (!(Queue.WebSocket is
null))
1507 await Queue.WebSocket.Send(Json.ToString(), 4096);
1508 else if (!(Queue.Response is
null))
1512 await Queue.Response.Write(
"[" + Json.ToString() +
"]");
1513 await Queue.Response.SendResponse();
1514 await Queue.Response.DisposeAsync();
1515 Queue.Response =
null;
1523 Queue.Queue.AddLast(s);
1527 if (!(Queue.SyncObj is
null))
1528 await Queue.SyncObj.EndWrite();
1532 timeoutByTabID.Remove(TabID);
1537 catch (Exception ex)
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
const string DefaultContentType
application/json
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Class representing an event.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
The ClientEvents class allows applications to push information asynchronously to web clients connecte...
static string[] GetTabIDsForUser(object User, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that a specific user views.
static async Task< int > PushEvent(string[] TabIDs, string Type, string Data, bool DataIsJson, string UserVariable, params string[] Privileges)
Puses an event to a set of Tabs, given their Tab IDs.
static string[] GetTabIDsForUser(object User, string Location)
Gets the Tab IDs of all tabs that a specific user views.
static void KeepTabAlive(string TabID, DateTime KeepAliveUntil)
Keeps a Tab alive, even though it might be temporarily offline or disconnected.
static string[] GetTabIDsForUser(object User, string Location, string QueryParameter1, string QueryParameterValue1)
Gets the Tab IDs of all tabs that a specific user views.
override bool UserSessions
If the resource uses user sessions.
static string[] GetOpenLocations()
Returns a list of resources that are currently open.
static object[] GetActiveUsers()
Returns a list of active users
bool AllowsGET
If the GET method is allowed.
static string[] GetTabIDsForLocation(string Location, string QueryParameter1, string QueryParameterValue1)
Gets the Tab IDs of all tabs that display a particular resource.
static TabInformation GetTabIDInformation(string TabID)
Gets information about a Tab, given its ID.
static string[] GetTabIDsForUser(object User, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1, string QueryParameter2, string QueryParameterValue2)
Gets the Tab IDs of all tabs that a specific user views.
override bool HandlesSubPaths
If the resource handles sub-paths.
static string[] GetTabIDsForLocation(string Location)
Gets the Tab IDs of all tabs that display a particular resource.
static async Task ReportAsynchronousResult(string Id, string ContentType, bool ConstantBuffer, byte[] Result, bool More)
Reports asynchronously evaluated result back to a client.
const int TabIdCacheTimeoutSeconds
Number of seconds before a Tab ID is purged, unless references or kept alive.
static Task< int > PushEvent(string[] TabIDs, string Type, object Data)
Puses an event to a set of Tabs, given their Tab IDs.
static string[] GetTabIDsForLocation(string Location, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that display a particular resource.
static string[] GetTabIDsForUser(object User, string Location, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1, string QueryParameter2, string QueryParameterValue2)
Gets the Tab IDs of all tabs that a specific user views.
static string[] GetTabIDsForUser(object User, string Location, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1)
Gets the Tab IDs of all tabs that a specific user views.
async Task GET(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
static Task ReportAsynchronousResult(string Id, string ContentType, bool ConstantBuffer, byte[] Result)
Reports asynchronously evaluated result back to a client.
static Task< int > PushEvent(string[] TabIDs, string Type, string Data, bool DataIsJson)
Puses an event to a set of Tabs, given their Tab IDs.
static string[] GetTabIDsForLocation(string Location, bool IgnoreCase, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that display a particular resource.
const int TabIdCacheTimeoutSecondsHalf
Half of TabIdCacheTimeoutSeconds.
static string[] GetTabIDsForLocation(string Location, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1, string QueryParameter2, string QueryParameterValue2)
Gets the Tab IDs of all tabs that display a particular resource.
static string[] GetTabIDsForLocations(params string[] Locations)
Gets the Tab IDs of all tabs that display a set of resources.
static string[] GetTabIDsForLocation(string Location, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1)
Gets the Tab IDs of all tabs that display a particular resource.
static string[] GetTabIDsForUser(object User, bool IgnoreCase, string QueryParameter1, string QueryParameterValue1)
Gets the Tab IDs of all tabs that a specific user views.
ClientEvents()
Resource managing asynchronous events to web clients.
static string[] GetTabIDsForUser(object User)
Gets the Tab IDs of all tabs that a specific user views.
bool AllowsPOST
If the POST method is allowed.
static string[] GetTabIDs()
Gets all open Tab IDs.
static string[] GetTabIDsForUser(object User, string Location, bool IgnoreCase, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that a specific user views.
static string[] GetTabIDsForUser(object User, string Location, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that a specific user views.
static Task< int > PushEvent(string[] TabIDs, string Type, string Data)
Puses an event to a set of Tabs, given their Tab IDs.
static string[] GetTabIDsForLocation(string Location, string QueryParameter1, string QueryParameterValue1, string QueryParameter2, string QueryParameterValue2)
Gets the Tab IDs of all tabs that display a particular resource.
static string[] GetTabIDsForUser(object User, string Location, string QueryParameter1, string QueryParameterValue1, string QueryParameter2, string QueryParameterValue2)
Gets the Tab IDs of all tabs that a specific user views.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
static string[] GetTabIDsForUser(object User, bool IgnoreCase, params KeyValuePair< string, string >[] QueryFilter)
Gets the Tab IDs of all tabs that a specific user views.
static string[] GetTabIDsForUsers()
Gets all open Tab IDs for logged in users.
Static class managing the runtime environment of the IoT Gateway.
static DateTime ScheduleEvent(Action< object > Callback, DateTime When, object State)
Schedules a one-time event.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Base class for all asynchronous HTTP resources. An asynchronous resource responds outside of the meth...
Represents an HTTP request.
HttpRequestHeader Header
Request header.
bool HasData
If the request has data.
SessionVariables Session
Contains session states, if the resource requires sessions, or null otherwise.
string SubPath
Sub-path. If a resource is found handling the request, this property contains the trailing sub-path o...
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
static string GetSessionId(HttpRequest Request, HttpResponse Response)
Gets the session ID used for a request.
static void SetTransparentCorsHeaders(HttpResource Resource, HttpRequest Request, HttpResponse Response)
Sets CORS headers for a resource, allowing it to be embedded in other sites.
const string HttpSessionID
The Cookie Key for HTTP Session Identifiers: "HttpSessionID"
Represets a response of an HTTP client request.
async Task DisposeAsync()
Closes the connection and disposes of all resources.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Write(byte[] Data)
Returns binary data in the response.
void SetHeader(string FieldName, string Value)
Sets a custom header field value.
The server encountered an unexpected condition which prevented it from fulfilling the request.
Collection of session variables.
void Dispose()
IDisposable.Dispose
override bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Event arguments for websocket events.
Class handling a web-socket.
async Task< bool > Send(string Payload, int MaxFrameLength)
Sends a text payload, possibly in multiple frames.
HttpResponse HttpResponse
Original HTTP response used when connection was upgrades to a WebSocket connection.
HttpRequest HttpRequest
Original HTTP request made to upgrade the connection to a WebSocket connection.
Generic object. Contains a sequence of properties.
Implements an in-memory cache.
Event arguments for cache item removal events.
ValueType Value
Value of item that was removed.
RemovedReason Reason
Reason for removing the item.
Represents an object that allows single concurrent writers but multiple concurrent readers....
virtual async Task< bool > TryBeginWrite(int Timeout)
Waits, at most Timeout milliseconds, until object ready for writing. Each successful call to TryBegi...
virtual void Dispose()
IDisposable.Dispose
Contains information about a variable.
Interface for asynchronously disposable objects.
GET Interface for HTTP resources.
POST Interface for HTTP resources.
Basic interface for all types of elements.
Basic interface for a user.
RemovedReason
Reason for removing the item.
ContentType
DTLS Record content type.