Compare commits
No commits in common. "eea090d2654475670ba585cf1b5d426c21ddf4ae" and "573a8e57bcfa9140c509aea7d2b063ba104d8f6d" have entirely different histories.
eea090d265
...
573a8e57bc
4 changed files with 23 additions and 58 deletions
|
@ -295,17 +295,6 @@ class CentralManagement():
|
||||||
self.currentHit.open_page_at = datetime.datetime.utcnow()
|
self.currentHit.open_page_at = datetime.datetime.utcnow()
|
||||||
self.store.saveHIT(self.currentHit)
|
self.store.saveHIT(self.currentHit)
|
||||||
self.setLight(True)
|
self.setLight(True)
|
||||||
elif signal.name == 'server.close':
|
|
||||||
if not signal.params['abandoned']:
|
|
||||||
continue
|
|
||||||
a = self.currentHit.getLastAssignment()
|
|
||||||
if a.assignment_id != signal.params['assignment_id']:
|
|
||||||
self.logger.info(f"Close of older assignment_id: {signal}")
|
|
||||||
continue
|
|
||||||
self.logger.critical(f"Websocket closed of active assignment_id: {signal}")
|
|
||||||
a.abandoned_at = datetime.datetime.utcnow()
|
|
||||||
self.store.saveAssignment(a)
|
|
||||||
self.plotter.park()
|
|
||||||
elif signal.name == 'assignment.submit':
|
elif signal.name == 'assignment.submit':
|
||||||
a = self.currentHit.getLastAssignment()
|
a = self.currentHit.getLastAssignment()
|
||||||
if a.assignment_id != signal.params['assignment_id']:
|
if a.assignment_id != signal.params['assignment_id']:
|
||||||
|
|
|
@ -56,8 +56,6 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
self.plotterQ = plotterQ
|
self.plotterQ = plotterQ
|
||||||
self.eventQ = eventQ
|
self.eventQ = eventQ
|
||||||
self.store = store
|
self.store = store
|
||||||
self.assignment_id = None
|
|
||||||
self.abandoned = False
|
|
||||||
|
|
||||||
def check_origin(self, origin):
|
def check_origin(self, origin):
|
||||||
parsed_origin = urlparse(origin)
|
parsed_origin = urlparse(origin)
|
||||||
|
@ -81,8 +79,7 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
if self.assignment.assignment_id != self.assignment_id:
|
if self.assignment.assignment_id != self.assignment_id:
|
||||||
raise Exception(f"Opening websocket for invalid assignment {self.assignment_id}")
|
raise Exception(f"Opening websocket for invalid assignment {self.assignment_id}")
|
||||||
|
|
||||||
self.timeout = self.assignment.created_at + datetime.timedelta(seconds=self.store.getHitTimeout())
|
self.timeout = datetime.datetime.now() + datetime.timedelta(seconds=self.store.getHitTimeout())
|
||||||
# timeLeft = (self.timeout - datetime.datetime.utcnow()).total_seconds()
|
|
||||||
|
|
||||||
if self.hit.isSubmitted():
|
if self.hit.isSubmitted():
|
||||||
raise Exception("Opening websocket for already submitted hit")
|
raise Exception("Opening websocket for already submitted hit")
|
||||||
|
@ -92,7 +89,6 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
self.strokes = []
|
self.strokes = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# the client sent the message
|
# the client sent the message
|
||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
logger.debug(f"recieve: {message}")
|
logger.debug(f"recieve: {message}")
|
||||||
|
@ -101,7 +97,7 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
logger.critical(f"Skip message for non-last assignment {message}")
|
logger.critical(f"Skip message for non-last assignment {message}")
|
||||||
return
|
return
|
||||||
|
|
||||||
if datetime.datetime.utcnow() > self.timeout:
|
if datetime.datetime.now() > self.timeout:
|
||||||
logger.critical("Close websocket after timeout (abandon?)")
|
logger.critical("Close websocket after timeout (abandon?)")
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
@ -168,9 +164,6 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
# client disconnected
|
# client disconnected
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
self.__class__.rmConnection(self)
|
self.__class__.rmConnection(self)
|
||||||
if self.assignment_id:
|
|
||||||
self.eventQ.put(Signal('server.close', dict(assignment_id=self.assignment_id, abandoned=self.abandoned)))
|
|
||||||
|
|
||||||
logger.info(f"Client disconnected: {self.request.remote_ip}")
|
logger.info(f"Client disconnected: {self.request.remote_ip}")
|
||||||
# TODO: abandon assignment??
|
# TODO: abandon assignment??
|
||||||
|
|
||||||
|
@ -214,20 +207,6 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
return
|
return
|
||||||
cls.connections.remove(client)
|
cls.connections.remove(client)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def hasConnection(cls, client):
|
|
||||||
return client in cls.connections
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def timeoutConnectionForAssignment(cls, assignment_id):
|
|
||||||
logger.warn(f"Check timeout for {assignment_id}")
|
|
||||||
for client in cls.connections:
|
|
||||||
logger.info(client.assignment_id)
|
|
||||||
if client.assignment_id == assignment_id:
|
|
||||||
client.abandoned = True
|
|
||||||
client.close()
|
|
||||||
|
|
||||||
|
|
||||||
class StatusWebSocketHandler(tornado.websocket.WebSocketHandler):
|
class StatusWebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
CORS_ORIGINS = ['localhost']
|
CORS_ORIGINS = ['localhost']
|
||||||
|
@ -332,8 +311,6 @@ class DrawPageHandler(tornado.web.RequestHandler):
|
||||||
logger.warning(f"Create new assignment {assignmentId}")
|
logger.warning(f"Create new assignment {assignmentId}")
|
||||||
assignment = self.store.newAssignment(self.store.currentHit, assignmentId)
|
assignment = self.store.newAssignment(self.store.currentHit, assignmentId)
|
||||||
self.store.saveAssignment(assignment)
|
self.store.saveAssignment(assignment)
|
||||||
logger.info(f"Set close timeout for {self.store.getHitTimeout()}")
|
|
||||||
Server.loop.asyncio_loop.call_later(self.store.getHitTimeout(), WebSocketHandler.timeoutConnectionForAssignment, assignment.assignment_id)
|
|
||||||
|
|
||||||
previous_hit = self.store.getLastSubmittedHit()
|
previous_hit = self.store.getLastSubmittedHit()
|
||||||
if not previous_hit:
|
if not previous_hit:
|
||||||
|
@ -455,6 +432,7 @@ class StatusPage():
|
||||||
return [hit.toDict() for hit in hits]
|
return [hit.toDict() for hit in hits]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Server:
|
class Server:
|
||||||
"""
|
"""
|
||||||
Server for HIT -> plotter events
|
Server for HIT -> plotter events
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="210mm"
|
id="svg8"
|
||||||
height="210mm"
|
|
||||||
viewBox="0 0 210 210"
|
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg8">
|
viewBox="0 0 210 210"
|
||||||
|
height="210mm"
|
||||||
|
width="210mm">
|
||||||
<defs
|
<defs
|
||||||
id="defs2" />
|
id="defs2" />
|
||||||
<metadata
|
<metadata
|
||||||
|
@ -25,15 +25,14 @@
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</metadata>
|
</metadata>
|
||||||
<g
|
<g
|
||||||
style="stroke-width:1.52441633"
|
transform="translate(0,-87)"
|
||||||
id="layer1"
|
id="layer1">
|
||||||
transform="matrix(0.65598879,0,0,0.65598879,44.11553,-86.509667)">
|
|
||||||
<rect
|
<rect
|
||||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.52441633;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.75590557;stroke-opacity:1"
|
y="138.32738"
|
||||||
id="rect815"
|
|
||||||
width="107.34524"
|
|
||||||
height="107.34524"
|
|
||||||
x="51.327381"
|
x="51.327381"
|
||||||
y="138.32738" />
|
height="107.34524"
|
||||||
|
width="107.34524"
|
||||||
|
id="rect815"
|
||||||
|
style="fill:none;fill-opacity:1;stroke:white;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.75590557;stroke-opacity:1" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1 KiB |
|
@ -13,7 +13,7 @@
|
||||||
height="180mm"
|
height="180mm"
|
||||||
preserveAspectRatio="none"
|
preserveAspectRatio="none"
|
||||||
id="svg3"
|
id="svg3"
|
||||||
sodipodi:docname="basic_square.svg"
|
sodipodi:docname="000139.svg"
|
||||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
|
||||||
<metadata
|
<metadata
|
||||||
id="metadata9">
|
id="metadata9">
|
||||||
|
@ -37,23 +37,22 @@
|
||||||
guidetolerance="10"
|
guidetolerance="10"
|
||||||
inkscape:pageopacity="0"
|
inkscape:pageopacity="0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:window-width="3840"
|
inkscape:window-width="3836"
|
||||||
inkscape:window-height="2160"
|
inkscape:window-height="2126"
|
||||||
id="namedview5"
|
id="namedview5"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
inkscape:zoom="1.3875926"
|
inkscape:zoom="1.3875926"
|
||||||
inkscape:cx="-14.783892"
|
inkscape:cx="311.32047"
|
||||||
inkscape:cy="589.76197"
|
inkscape:cy="589.76197"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="2"
|
||||||
inkscape:window-y="0"
|
inkscape:window-y="32"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="1"
|
||||||
inkscape:current-layer="svg3"
|
inkscape:current-layer="svg3" />
|
||||||
showguides="false" />
|
|
||||||
<rect
|
<rect
|
||||||
style="fill:none;fill-opacity:1;stroke:#808080;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.75590557;stroke-opacity:1"
|
style="fill:none;fill-opacity:1;stroke:#808080;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.75590557;stroke-opacity:1"
|
||||||
id="rect819"
|
id="rect819"
|
||||||
width="306.99152"
|
width="306.99152"
|
||||||
height="306.99152"
|
height="306.99152"
|
||||||
x="1287.0762"
|
x="1287.0762"
|
||||||
y="165.88982" />
|
y="638.77118" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue