forked from Monkestation/Monkestation2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plexora_hrp_thing.patch
47 lines (43 loc) · 1.75 KB
/
plexora_hrp_thing.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/monkestation/code/controllers/subsystem/plexora.dm b/monkestation/code/controllers/subsystem/plexora.dm
index 8fc9f68ace0..bd54b98fe34 100644
--- a/monkestation/code/controllers/subsystem/plexora.dm
+++ b/monkestation/code/controllers/subsystem/plexora.dm
@@ -44,6 +44,9 @@ SUBSYSTEM_DEF(plexora)
var/tripped_bad_version = FALSE
var/list/default_headers
+ //other thingys!
+ var/hrp_available = FALSE
+
/datum/controller/subsystem/plexora/Initialize()
if (!rustg_file_exists(configuration_path))
stack_trace("SSplexora has no configuration file! (missing: [configuration_path])")
@@ -117,6 +120,7 @@ SUBSYSTEM_DEF(plexora)
return TRUE
/datum/controller/subsystem/plexora/fire()
+ hrp_available = check_byondserver_status("7cfa7daf")
if(!is_plexora_alive()) return
// Send current status to Plexora
var/datum/world_topic/status/status_handler = new()
@@ -194,6 +198,24 @@ SUBSYSTEM_DEF(plexora)
"computer_id" = interview.owner?.computer_id,
))
+/datum/controller/subsystem/plexora/proc/check_byondserver_status(id)
+ if (isnull(id)) return
+
+ var/list/body = list(
+ "id" = id
+ )
+
+ var/datum/http_request/request = new(RUSTG_HTTP_METHOD_GET, "http://[http_root]:[http_port]/byondserver_alive", json_encode(body))
+ request.begin_async()
+ UNTIL_OR_TIMEOUT(request.is_complete(), 5 SECONDS)
+ var/datum/http_response/response = request.into_response()
+ if (response.errored)
+ stack_trace("check_byondserver_status failed, likely an bad id passed ([id]) aka id of a server that doesnt exist")
+ return FALSE
+ else
+ var/list/json_body = json_decode(response.body)
+ return json_body["alive_likely"]
+
// note: recover_all_SS_and_recreate_master to force mc shit
/datum/controller/subsystem/plexora/proc/mc_alert(alert, level = 5)