mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-24 05:23:22 +01:00
Attempt to fix blank chat / chat not loading (#21868)
if this works im going to cry if it doesn't work i am also going to cry duality of man
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* Copyright (c) 2020 Aleksej Komarov
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maximum number of connection records allowed to analyze.
|
||||
* Should match the value set in the browser.
|
||||
*/
|
||||
#define TGUI_TELEMETRY_MAX_CONNECTIONS 5
|
||||
|
||||
/**
|
||||
* Maximum time allocated for sending a telemetry packet.
|
||||
*/
|
||||
#define TGUI_TELEMETRY_RESPONSE_WINDOW (30 SECONDS)
|
||||
|
||||
/// Time of telemetry request
|
||||
/datum/tgui_panel/var/telemetry_requested_at
|
||||
/// Time of telemetry analysis completion
|
||||
/datum/tgui_panel/var/telemetry_analyzed_at
|
||||
/// List of previous client connections
|
||||
/datum/tgui_panel/var/list/telemetry_connections
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Requests some telemetry from the client.
|
||||
*/
|
||||
/datum/tgui_panel/proc/request_telemetry()
|
||||
telemetry_requested_at = world.time
|
||||
telemetry_analyzed_at = null
|
||||
window.send_message("telemetry/request", list(
|
||||
"limits" = list(
|
||||
"connections" = TGUI_TELEMETRY_MAX_CONNECTIONS,
|
||||
),
|
||||
))
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
* Analyzes a telemetry packet.
|
||||
*
|
||||
* Does nothing except kick people who try to send a billion requests.
|
||||
*/
|
||||
/datum/tgui_panel/proc/analyze_telemetry(payload)
|
||||
if(world.time > telemetry_requested_at + TGUI_TELEMETRY_RESPONSE_WINDOW)
|
||||
message_admins("[key_name(client)] sent telemetry outside of the allocated time window.")
|
||||
return
|
||||
if(telemetry_analyzed_at)
|
||||
message_admins("[key_name(client)] sent telemetry more than once.")
|
||||
return
|
||||
telemetry_analyzed_at = world.time
|
||||
if(!payload)
|
||||
return
|
||||
telemetry_connections = payload["connections"]
|
||||
var/len = length(telemetry_connections)
|
||||
if(len == 0)
|
||||
return
|
||||
if(len > TGUI_TELEMETRY_MAX_CONNECTIONS)
|
||||
message_admins("[key_name(client)] was kicked for sending a huge telemetry payload")
|
||||
qdel(client)
|
||||
return
|
||||
|
||||
var/ckey = client?.ckey
|
||||
if (!ckey)
|
||||
return
|
||||
|
||||
#undef TGUI_TELEMETRY_MAX_CONNECTIONS
|
||||
#undef TGUI_TELEMETRY_RESPONSE_WINDOW
|
||||
@@ -51,7 +51,9 @@
|
||||
window.send_asset(get_asset_datum(/datum/asset/simple/namespaced/tgfont))
|
||||
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
|
||||
// Other setup
|
||||
request_telemetry()
|
||||
addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS)
|
||||
window.send_message("testTelemetryCommand")
|
||||
|
||||
/**
|
||||
* private
|
||||
|
||||
Reference in New Issue
Block a user