mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-25 21:19:00 +01:00
Merge pull request #1367 from CIB/master
Implemented socket_talk, a quick way for inter-process communication
This commit is contained in:
@@ -137,6 +137,7 @@
|
||||
|
||||
src.update_status()
|
||||
|
||||
socket_talk = new /datum/socket_talk()
|
||||
master_controller = new /datum/controller/game_controller()
|
||||
spawn(-1)
|
||||
master_controller.setup()
|
||||
|
||||
@@ -22,17 +22,30 @@ 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()
|
||||
|
||||
// notify the other process that we started up
|
||||
socket_talk.send_raw("type=startup")
|
||||
|
||||
if(!air_master)
|
||||
air_master = new /datum/controller/air_system()
|
||||
air_master.setup()
|
||||
@@ -73,6 +86,8 @@ datum/controller/game_controller
|
||||
|
||||
setupfactions()
|
||||
|
||||
spawn keepalive()
|
||||
|
||||
spawn
|
||||
ticker.pregame()
|
||||
|
||||
@@ -109,7 +124,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_raw("type=ticker_state&message=[txt]")
|
||||
return
|
||||
|
||||
process()
|
||||
@@ -141,6 +156,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
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Module used for fast interprocess communication between BYOND and other processes
|
||||
|
||||
/datum/socket_talk
|
||||
var
|
||||
enabled = 0
|
||||
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