mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Refined the BYOND-side socket_talk interface
This commit is contained in:
@@ -22,17 +22,27 @@ datum/controller/game_controller
|
||||
var/global/ticker_ready = 0
|
||||
|
||||
proc
|
||||
keepalive()
|
||||
setup()
|
||||
setup_objects()
|
||||
process()
|
||||
set_debug_state(txt)
|
||||
|
||||
keepalive()
|
||||
spawn while(1)
|
||||
sleep(10)
|
||||
|
||||
// Notify the other process that we're still there
|
||||
socket_talk.send_keepalive()
|
||||
|
||||
setup()
|
||||
if(master_controller && (master_controller != src))
|
||||
del(src)
|
||||
return
|
||||
//There can be only one master.
|
||||
|
||||
socket_talk = new /datum/socket_talk()
|
||||
|
||||
if(!air_master)
|
||||
air_master = new /datum/controller/air_system()
|
||||
air_master.setup()
|
||||
@@ -73,6 +83,8 @@ datum/controller/game_controller
|
||||
|
||||
setupfactions()
|
||||
|
||||
spawn keepalive()
|
||||
|
||||
spawn
|
||||
ticker.pregame()
|
||||
|
||||
@@ -109,7 +121,7 @@ datum/controller/game_controller
|
||||
// This should describe what is currently being done by the master controller
|
||||
// Useful for crashlogs and similar, because that way it's easy to tell what
|
||||
// was going on when the server crashed.
|
||||
|
||||
socket_talk.send_log("crashlog.txt","TickerState: [txt]")
|
||||
return
|
||||
|
||||
process()
|
||||
@@ -141,6 +153,9 @@ datum/controller/game_controller
|
||||
powernets_ready = 0
|
||||
ticker_ready = 0
|
||||
|
||||
// Notify the other process that we're still there
|
||||
socket_talk.send_keepalive()
|
||||
|
||||
// the fact that the air master is not in the master controller
|
||||
// will make it very hard to find out whether it's responsible
|
||||
// for crashes
|
||||
|
||||
27
code/game/socket_talk.dm
Normal file
27
code/game/socket_talk.dm
Normal file
@@ -0,0 +1,27 @@
|
||||
// Module used for fast interprocess communication between BYOND and other processes
|
||||
|
||||
/datum/socket_talk
|
||||
var
|
||||
enabled = 0
|
||||
library_name =
|
||||
New()
|
||||
..()
|
||||
src.enabled = config.socket_talk
|
||||
|
||||
if(enabled)
|
||||
call("DLLSocket.so","establish_connection")("127.0.0.1","8019")
|
||||
|
||||
proc
|
||||
send_raw(message)
|
||||
if(enabled)
|
||||
return call("DLLSocket.so","send_message")(message)
|
||||
receive_raw()
|
||||
if(enabled)
|
||||
return call("DLLSocket.so","recv_message")()
|
||||
send_log(var/log, var/message)
|
||||
return send_raw("type=log&log=[log]&message=[message]")
|
||||
send_keepalive()
|
||||
return send_raw("type=keepalive")
|
||||
|
||||
|
||||
var/global/datum/socket_talk/socket_talk
|
||||
Reference in New Issue
Block a user