예제 #1
0
 def wrapper(self, request):
     content = build_object(json_decode(request.content.getvalue()))
     session = sm.get_session(find_session_id(request))
     if not session:
         return json_encode({'link_status': 'session_not_found'})
     try:
         result = func(self, content, session)
         if result is None:
             request.setResponseCode(204)
             return ''
         return json_encode(result)
     except PermError:
         request.setResponseCode(403)
         return "Permission Denied."
     except DataError as de:
         request.setResponseCode(409)
         return str(de.message)
     except StateError as se:
         request.setResponseCode(400)
         return str(se.message)
예제 #2
0
 def render_POST(self, request):
     content = build_object(json_decode(request.content.getvalue()))
     session_id = find_session_id(request)
     if session_id:
         return json_encode(sm.reconnect_session(session_id, content.player_id))
     return json_encode(sm.start_session())