summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-15 19:30:39 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-15 19:30:39 -0300
commitc9f52fa50a9361951b03116f77bc38f5e49f4bf8 (patch)
treeb9eb88827c2672194597fe9ea14f2a244ad1c023
parent8610f918a5ffcc047b45c5182a63a3fc6a0dd318 (diff)
downloadclient-c9f52fa50a9361951b03116f77bc38f5e49f4bf8.tar.gz
client-c9f52fa50a9361951b03116f77bc38f5e49f4bf8.tar.bz2
client-c9f52fa50a9361951b03116f77bc38f5e49f4bf8.tar.xz
client-c9f52fa50a9361951b03116f77bc38f5e49f4bf8.zip
Optimize packet flow
-rw-r--r--game/defs.rpy18
-rw-r--r--game/script.rpy4
2 files changed, 12 insertions, 10 deletions
diff --git a/game/defs.rpy b/game/defs.rpy
index ad0e6dd..0fce7c1 100644
--- a/game/defs.rpy
+++ b/game/defs.rpy
@@ -440,11 +440,6 @@ init -1 python:
global tr_load, tr_val, tr_busy
global ws
- # TODO: if tr_busy already true, wait until it is made false
- tr_busy=True
- tr_load=False
- tr_val=""
-
stdout("Sending: %s" % packet)
try:
ws.send(get_token() + ";" + packet + ";" + args)
@@ -457,17 +452,23 @@ init -1 python:
def send_packet(packet, args=""):
global tr_load, tr_val, tr_busy
# TODO: if tr_busy already true, wait until it is made false
+ while tr_busy:
+ renpy.pause(0.02)
+
+ # Book processing space for ourselves
+ tr_busy=True
+ tr_load=False
+ tr_val=None
- # This is a secret variable which disables threading
+ # This is a secret variable which disables threading and queue
# This may cause hangs and other issues.
if persistent.nothreading:
send_packet_now(packet, args)
+ tr_busy=False
val=tr_val
return val
timeout=0.0
- tr_load=False
- tr_val=None
renpy.show("spinner", at_list=[truecenter])
renpy.invoke_in_thread(send_packet_now, packet, args)
while not tr_load:
@@ -486,6 +487,7 @@ init -1 python:
renpy.hide("spinner")
val=tr_val
+ tr_busy=False
del tr_val
print "value obtained"
diff --git a/game/script.rpy b/game/script.rpy
index ad0e091..f5fc1af 100644
--- a/game/script.rpy
+++ b/game/script.rpy
@@ -26,7 +26,7 @@ init python:
# Same as ondata?
def onmsg(self, message):
global tr_load, tr_val, tr_busy
- stdout(message)
+ stdout("Server : " + message)
# Inform whatever is waiting for us that a reply was obtained
tr_load=True
@@ -35,7 +35,7 @@ init python:
return
def ondata(self, msg, dtype, cont):
- print("data received")
+ #print("data received")
"""
on_data: callback object which is called when a message received.
This is called before on_message or on_cont_message,