summaryrefslogtreecommitdiffstats
path: root/webapp/app/views.py
diff options
context:
space:
mode:
authorgroup1 <f16_group1@pbridge.adm.cs.cmu.edu>2016-10-09 14:45:03 -0400
committergroup1 <f16_group1@pbridge.adm.cs.cmu.edu>2016-10-09 14:45:03 -0400
commitdfe1127addf7e31acd63e87db0a5d5e35628ea67 (patch)
tree101526e338590ba0980ff1809a8338cd12b50b4e /webapp/app/views.py
parentScale the amount to change by the distance (diff)
downloadbridge-dfe1127addf7e31acd63e87db0a5d5e35628ea67.tar.zst
Add twinkle
Diffstat (limited to 'webapp/app/views.py')
-rw-r--r--webapp/app/views.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/webapp/app/views.py b/webapp/app/views.py
new file mode 100644
index 0000000..4aa2c05
--- /dev/null
+++ b/webapp/app/views.py
@@ -0,0 +1,37 @@
+from flask import render_template, request
+from app import app, sio
+import time
+
+import threading
+
+thread = None
+
+@app.route('/')
+@app.route('/index')
+def index():
+ return render_template('index.html',
+ title='F16 Group1')
+
+connections = set()
+
+@sio.on('connect', namespace='/spawn')
+def connect(sid, environ):
+ print("connect ", sid)
+ connections.add(sid)
+
+@sio.on('spawn', namespace='/spawn')
+def message(sid, data):
+ print("message ", data)
+
+@sio.on('disconnect', namespace='/spawn')
+def disconnect(sid):
+ print('disconnect', sid)
+ connections.remove(sid)
+
+
+
+def add_creature():
+ time.sleep(5)
+ sio.emit('new creature', {'name': 'fish1'}, namespace='/spawn')
+
+thread = sio.start_background_task(add_creature)