fix poll api for remotes

This commit is contained in:
Tim Bentley 2016-09-30 20:50:48 +01:00
parent c6c7931323
commit c5e761a153
3 changed files with 6 additions and 3 deletions

View File

@ -107,13 +107,15 @@ def index(request):
return blank_endpoint.render_template('index.mako', **TRANSLATED_STRINGS)
@blank_endpoint.route('api/poll')
@blank_endpoint.route('poll')
def poll(request):
"""
Deliver the page for the /poll url
:param request:
"""
return Registry().get('poller').raw_poll()
return Registry().get('poller').poll()
@blank_endpoint.route('api/display/{display:hide|show|blank|theme|desktop}')

View File

@ -53,7 +53,7 @@ class Poller(RegistryProperties):
"""
Poll OpenLP to determine the current slide number and item name.
"""
return json.dumps({'results': self.raw_poll()}).encode()
return {'results': self.raw_poll()}
def main_poll(self):
"""

View File

@ -27,6 +27,7 @@ with OpenLP. It uses JSON to communicate with the remotes.
import asyncio
import websockets
import json
import logging
import time
@ -130,7 +131,7 @@ class WebSocketServer(RegistryProperties, OpenLPMixin):
while True:
current_poll = poller.poll()
if current_poll != previous_poll:
yield from request.send(current_poll)
yield from request.send(json.dumps(current_poll).encode())
previous_poll = current_poll
yield from asyncio.sleep(0.2)
elif path == '/live_changed':