diff options
| author | RblSb <msrblsb@gmail.com> | 2025-01-29 20:37:50 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2025-01-29 20:42:01 +0300 |
| commit | 382f9b2ebedca905028341825350a0fa69d88673 (patch) | |
| tree | f627cd270d893452c13f3d0916ea75673c39607e /src/server/Main.hx | |
| parent | 0592564264fff57ccfd9677957196951f9f1c6cf (diff) | |
Cleanup
- PWA support (needs https)
- Optimize websocket responses
- Support `/ad` for youtube cache
- New icon!
Diffstat (limited to 'src/server/Main.hx')
| -rw-r--r-- | src/server/Main.hx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx index 4f0fd03..d5c0800 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -940,7 +940,7 @@ class Main { }), logs: logger.getLogs() } - final json = Json.stringify(data, logger.filterNulls, "\t"); + final json = jsonStringify(data, "\t"); send(client, { type: Dump, dump: { @@ -984,23 +984,34 @@ class Main { } public function send(client:Client, data:WsEvent):Void { - client.ws.send(Json.stringify(data), null); + client.ws.send(jsonStringify(data), null); } public function broadcast(data:WsEvent):Void { - final json = Json.stringify(data); + final json = jsonStringify(data); for (client in clients) client.ws.send(json, null); } public function broadcastExcept(skipped:Client, data:WsEvent):Void { - final json = Json.stringify(data); + final json = jsonStringify(data); for (client in clients) { if (client == skipped) continue; client.ws.send(json, null); } } + public static function jsonStringify(data:Any, ?space:String):String { + return Json.stringify(data, jsonFilterNulls, space); + } + + static function jsonFilterNulls(key:Any, value:Any):Any { + #if js + if (value == null) return js.Lib.undefined; + #end + return value; + } + function skipVideo(data:WsEvent):Void { if (videoList.length == 0) return; final item = videoList.currentItem; |
