forked from openlp/openlp
fix poll api for remotes
This commit is contained in:
parent
c6c7931323
commit
c5e761a153
@ -107,13 +107,15 @@ def index(request):
|
|||||||
return blank_endpoint.render_template('index.mako', **TRANSLATED_STRINGS)
|
return blank_endpoint.render_template('index.mako', **TRANSLATED_STRINGS)
|
||||||
|
|
||||||
|
|
||||||
|
@blank_endpoint.route('api/poll')
|
||||||
@blank_endpoint.route('poll')
|
@blank_endpoint.route('poll')
|
||||||
def poll(request):
|
def poll(request):
|
||||||
"""
|
"""
|
||||||
Deliver the page for the /poll url
|
Deliver the page for the /poll url
|
||||||
|
|
||||||
:param request:
|
:param request:
|
||||||
"""
|
"""
|
||||||
return Registry().get('poller').raw_poll()
|
return Registry().get('poller').poll()
|
||||||
|
|
||||||
|
|
||||||
@blank_endpoint.route('api/display/{display:hide|show|blank|theme|desktop}')
|
@blank_endpoint.route('api/display/{display:hide|show|blank|theme|desktop}')
|
||||||
|
@ -53,7 +53,7 @@ class Poller(RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Poll OpenLP to determine the current slide number and item name.
|
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):
|
def main_poll(self):
|
||||||
"""
|
"""
|
||||||
|
@ -27,6 +27,7 @@ with OpenLP. It uses JSON to communicate with the remotes.
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import websockets
|
import websockets
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ class WebSocketServer(RegistryProperties, OpenLPMixin):
|
|||||||
while True:
|
while True:
|
||||||
current_poll = poller.poll()
|
current_poll = poller.poll()
|
||||||
if current_poll != previous_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
|
previous_poll = current_poll
|
||||||
yield from asyncio.sleep(0.2)
|
yield from asyncio.sleep(0.2)
|
||||||
elif path == '/live_changed':
|
elif path == '/live_changed':
|
||||||
|
Loading…
Reference in New Issue
Block a user