mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-14 04:02:31 +00:00
Refined the socket_talk protocol for debugging purposes.
This commit is contained in:
@@ -9,6 +9,8 @@ sock = socket.socket( socket.AF_INET, # Internet
|
|||||||
socket.SOCK_DGRAM ) # UDP
|
socket.SOCK_DGRAM ) # UDP
|
||||||
sock.bind( (UDP_IP,UDP_PORT) )
|
sock.bind( (UDP_IP,UDP_PORT) )
|
||||||
|
|
||||||
|
last_ticker_state = None
|
||||||
|
|
||||||
def handle_message(data, addr):
|
def handle_message(data, addr):
|
||||||
params = urlparse.parse_qs(data)
|
params = urlparse.parse_qs(data)
|
||||||
print(data)
|
print(data)
|
||||||
@@ -20,6 +22,20 @@ def handle_message(data, addr):
|
|||||||
pass
|
pass
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if params["type"][0] == "ticker_state" and str(params["message"][0]):
|
||||||
|
last_ticker_state = str(params["message"][0])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
global last_ticker_state
|
||||||
|
if params["type"][0] == "startup" and last_ticker_state:
|
||||||
|
open("crashlog.txt","a+").write("Server exited, last ticker state was: "+last_ticker_state)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
|
data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ datum/controller/game_controller
|
|||||||
|
|
||||||
socket_talk = new /datum/socket_talk()
|
socket_talk = new /datum/socket_talk()
|
||||||
|
|
||||||
|
// notify the other process that we started up
|
||||||
|
socket_talk.send_raw("type=startup")
|
||||||
|
|
||||||
if(!air_master)
|
if(!air_master)
|
||||||
air_master = new /datum/controller/air_system()
|
air_master = new /datum/controller/air_system()
|
||||||
air_master.setup()
|
air_master.setup()
|
||||||
@@ -121,7 +124,7 @@ datum/controller/game_controller
|
|||||||
// This should describe what is currently being done by the master 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
|
// Useful for crashlogs and similar, because that way it's easy to tell what
|
||||||
// was going on when the server crashed.
|
// was going on when the server crashed.
|
||||||
socket_talk.send_log("crashlog.txt","TickerState: [txt]")
|
socket_talk.send_raw("type=ticker_state&message=[txt]")
|
||||||
return
|
return
|
||||||
|
|
||||||
process()
|
process()
|
||||||
|
|||||||
Reference in New Issue
Block a user