summaryrefslogtreecommitdiffstats
path: root/webapp/app/views.py
diff options
context:
space:
mode:
authorAaron Perley <aaron.perley@gmail.com>2016-10-17 14:54:06 -0400
committerAaron Perley <aaron.perley@gmail.com>2016-10-17 14:54:06 -0400
commit1b0d46151bb6e0d98787fa1cdcc3b5b80b7d2478 (patch)
tree6653e7e6614eb14fa6dea4e3b90b922275903a63 /webapp/app/views.py
parentebda59b316159f7e568c634cc5d906447928f973 (diff)
downloadbridge-1b0d46151bb6e0d98787fa1cdcc3b5b80b7d2478.tar.zst
Add sound effects
Diffstat (limited to 'webapp/app/views.py')
-rw-r--r--webapp/app/views.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/webapp/app/views.py b/webapp/app/views.py
index a13bf12..99c57c3 100644
--- a/webapp/app/views.py
+++ b/webapp/app/views.py
@@ -16,6 +16,19 @@ def send_static(path):
connections = set()
+@sio.on('connect', namespace='/music')
+def connect_music(sid, environ):
+ print("connect_music", sid)
+
+@sio.on('disconnect', namespace='/music')
+def disconnect_music(sid):
+ print("disconnect_music", sid)
+
+current_background_music = None
+@sio.on('ready', namespace='/music')
+def ready_music(sid):
+ sio.emit('background', {'id': current_background_music}, room=sid, namespace='/music')
+
@sio.on('connect', namespace='/spawn')
def connect(sid, environ):
print("connect ", sid)
@@ -25,6 +38,7 @@ def connect(sid, environ):
def message(sid, data):
print("message ", data)
send_queue.put(('spawn', data))
+ sio.emit('effect', {'id': data['type']}, namespace='/music');
@sio.on('ready', namespace='/spawn')
def ready(sid):
@@ -52,10 +66,17 @@ def recv_events():
event = recv_queue.get()
if event[0] == 'enable image':
fish_state[event[1]['name']] = 1
+ sio.emit('fish state', fish_state, namespace='/spawn')
elif event[0] == 'disable image':
fish_state[event[1]['name']] = 0
+ sio.emit('fish state', fish_state, namespace='/spawn')
+ elif event[0] == 'background music':
+ print "****** background music ", event[1]
+ sio.emit('background', {'id': event[1]}, namespace='/music');
+ current_background_music = event[1];
+ elif event[0] == 'effect music':
+ sio.emit('effect', {'id': event[1]}, namespace='/music');
- sio.emit('fish state', fish_state, namespace='/spawn')
thread = sio.start_background_task(recv_events)