diff options
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; |
