2using System.Collections.Generic;
3using System.Threading.Tasks;
24 : base(
"/ClientEventsWS", true, 10 * 1024 * 1024, 10 * 1024 * 1024,
"ls")
26 this.Accept += this.ClientEventsWebSocket_Accept;
27 this.Connected += this.ClientEventsWebSocket_Connected;
39 return base.GET(Request, Response);
44 e.Socket.Closed += this.Socket_Closed;
45 e.Socket.Disposed += this.Socket_Disposed;
46 e.Socket.TextReceived += this.Socket_TextReceived;
48 return Task.CompletedTask;
54 Obj.TryGetValue(
"cmd", out
object Value) && Value is
string Command)
59 if (Obj.TryGetValue(
"tabId", out
object O1) && O1 is
string TabID &&
60 Obj.TryGetValue(
"location", out
object O2) && O2 is
string Location)
62 e.Socket.Tag =
new Info()
70 await ClientEvents.RegisterWebSocket(e.
Socket, Location, TabID);
77 await ClientEvents.PushEvent(
new string[] { TabID },
"CheckServerInstance", serverId,
false);
82 await this.Close(e.
Socket);
87 ClientEvents.Ping(Info.TabID);
95 public string Location;
99 private async Task Socket_Disposed(
object Sender, EventArgs e)
107 return this.Close(e.
Socket);
110 private async Task Close(
WebSocket Socket)
112 if (Socket.
Tag is Info Info)
114 await ClientEvents.UnregisterWebSocket(Socket, Info.Location, Info.TabID);
131 return Task.CompletedTask;
Helps with common JSON-related tasks.
static object Parse(string Json)
Parses a JSON string.
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.
Web-socket binding method for the ClientEvents class. It allows clients connect to the gateway using ...
override bool HandlesSubPaths
If the resource handles sub-paths.
ClientEventsWebSocket()
Resource managing asynchronous events to web clients.
override Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
Static class managing the runtime environment of the IoT Gateway.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
Represents an HTTP request.
static void SetTransparentCorsHeaders(HttpResource Resource, HttpRequest Request, HttpResponse Response)
Sets CORS headers for a resource, allowing it to be embedded in other sites.
Represets a response of an HTTP client request.
Event arguments for websocket closed events.
Event arguments for websocket events.
WebSocket Socket
Web-socket
Class handling a web-socket.
object Tag
Applications can use this property to attach a value of any type to the websocket connection.
HTTP resource implementing the WebSocket Protocol as defined in RFC 6455: https://tools....
Event arguments for websocket text events.
string Payload
Text payload.
Contains methods for simple hash calculations.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).