summaryrefslogtreecommitdiff
path: root/game/script.rpy
diff options
context:
space:
mode:
Diffstat (limited to 'game/script.rpy')
-rw-r--r--game/script.rpy43
1 files changed, 43 insertions, 0 deletions
diff --git a/game/script.rpy b/game/script.rpy
index 7c98304..1db5d3f 100644
--- a/game/script.rpy
+++ b/game/script.rpy
@@ -21,6 +21,33 @@ by sending an email to {a=mailto:dmca@tmw2.org}dmca@tmw2.org{/a}.{/color}\n\
No warranties.{/b}{fast}"
return
+init python:
+ # Same as ondata?
+ def onmsg(self, message):
+ print(message)
+
+ def ondata(self, msg, dtype, cont):
+ print("data received")
+ """
+ on_data: callback object which is called when a message received.
+ This is called before on_message or on_cont_message,
+ and then on_message or on_cont_message is called.
+ on_data has 4 argument.
+ The 1st argument is this class object.
+ The 2nd argument is utf-8 string which we get from the server.
+ The 3rd argument is data type. ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY will be came.
+ The 4th argument is continue flag. if 0, the data continue
+ """
+ renpy.notify(msg)
+ return
+
+ def onopen(self):
+ print("Opening connection")
+ self.send("Ping")
+
+ def onerror(self, err):
+ print("ERROR RECEIVED")
+ raise err
# Inform you are now ingame
label start:
@@ -29,6 +56,22 @@ label start:
show spinner at truecenter
pause 0.1
+ "We shall now begin testing a websocket"
+ python:
+ # server, sock, address
+ # on_open=None, on_message=None, on_error=None,
+ # on_close=None, on_ping=None, on_pong=None,
+ # on_data=None):
+ ws = wsock.WebSocketApp("wss://localhost:61000",
+ on_data=ondata, on_error=onerror, on_open=onopen,
+ on_message=onmsg)
+ print repr(ws)
+ ws.on_open = onopen
+ renpy.invoke_in_thread(ws.run_forever, sslopt={"cert_reqs": ssl.CERT_NONE})
+ #ws.connect("wss://localhost:61000")
+
+ "Connection established!"
+ return
# Run updater
python:
tr_load=False