Skip to content

Commit

Permalink
feat: add seperate endpoints for player 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrefj committed Jul 23, 2024
1 parent 270be46 commit a884bcd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/webapp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def view_high_score(json_data):


@socketio.on("getExampleDrawings")
def get_example_drawings(json_data):
def get_example_drawings(json_data, emitEndpoint="getExampleDrawings"):
"""
Get example drawings from the database
"""
Expand All @@ -213,8 +213,15 @@ def get_example_drawings(json_data):
label, number_of_images)
example_drawings = storage.get_images_from_relative_url(
example_drawing_urls)
emit("getExampleDrawings", json.dumps(example_drawings), room=game_id)
emit(emitEndpoint, json.dumps(example_drawings), room=game_id)

@socketio.on("getExampleDrawingsP1")
def get_example_drawings_player_1(json_data):
get_example_drawings(json_data, emitEndpoint="getExampleDrawingsP1")

@socketio.on("getExampleDrawingsP2")
def get_example_drawings_player_2(json_data):
get_example_drawings(json_data, emitEndpoint="getExampleDrawingsP2")

@socketio.on("classify")
def handle_classify(data, image, correct_label=None):
Expand Down

0 comments on commit a884bcd

Please sign in to comment.