|
@@ -62,10 +62,7 @@ def update_gn_in_blender(msg_dict):
|
|
|
|
|
|
return object_name
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-def poll_for_messages():
|
|
|
+def poll_for_messages(idle_time: int, heartbeat_sent: bool):
|
|
|
# poll if there are messages until we exhaust them.
|
|
|
msg_str = MessageReader().as_string()
|
|
|
if len(msg_str) > 0:
|
|
@@ -91,6 +88,11 @@ def poll_for_messages():
|
|
|
map_id = msg_dict['MapId']
|
|
|
from lib_loader import GNLibs
|
|
|
GNLibs.ClearSHM(map_id)
|
|
|
-
|
|
|
- return True
|
|
|
- return False
|
|
|
+ heartbeat_sent = False
|
|
|
+ return True, heartbeat_sent # reset idle_time as we got a message from the server
|
|
|
+ else:
|
|
|
+ if idle_time > 2 and heartbeat_sent == False:
|
|
|
+ MessageWriter().from_buffer(bytes(json.dumps({'Heartbeat' : True }), "UTF-8")) # send a heartbeat message to the server
|
|
|
+ heartbeat_sent = True
|
|
|
+
|
|
|
+ return False, heartbeat_sent
|