Skip to content
Snippets Groups Projects
Commit eda5874e authored by Nils G.'s avatar Nils G.
Browse files

Added closed flag to rooms and http status code response 410 GONE

parent e2e0e634
No related branches found
No related tags found
No related merge requests found
from parameter_util import JSON_BODY, JSON_CONTAINS
from http_util import FAIL, CODE_JSON, CODE_MISSING, CODE_SEMANTIC
from http_util import FAIL, CODE_JSON, CODE_MISSING, CODE_SEMANTIC, CODE_GONE
from room_util import ROOM_GET, PLAYERS_GET
import random
......@@ -43,6 +43,9 @@ def status():
if not room_record:
return(FAIL(CODE_SEMANTIC))
if room_record.closed:
return(FAIL(CODE_GONE))
players = PLAYERS_GET(room_record)
json = {"players": players}
......
......@@ -7,13 +7,14 @@ db.define_table(
Field('hashcode', 'string', notnull=True),
Field('player_max', 'integer', notnull=True),
Field('creation', 'datetime', default=request.now, notnull=True),
Field('heartbeat', 'datetime', default=request.now, notnull=True)
Field('heartbeat', 'datetime', default=request.now, notnull=True),
Field('closed', 'boolean', default=False)
)
def generateRoomCode():
code = None
while not code or db(db.Room.code == code).count() > 0:
while not code or db((db.Room.code == code) & (db.Room.closed == False)).count() > 0:
code = ""
for i in range(4):
# Removed characters which could be confused like 0 and O
......
......@@ -2,6 +2,7 @@ from gluon import *
CODE_MISSING = 400
CODE_JSON = 406
CODE_GONE = 410
CODE_SEMANTIC = 422
def FAIL(_code):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment