From c694e901b0967b0d38c52f51f430b87cb0b6be98 Mon Sep 17 00:00:00 2001 From: GitBluub Date: Sat, 21 Jan 2023 17:26:25 +0900 Subject: [PATCH] send method --- scorometer/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scorometer/main.py b/scorometer/main.py index 1b9782e..b79cbc2 100755 --- a/scorometer/main.py +++ b/scorometer/main.py @@ -95,18 +95,21 @@ class Scorometer(): self.handleNote(obj) if obj["type"] == "pause": pass + + def send(self, o): + print(json.dumps(o), flush=True) def sendDebug(self, obj): - print(json.dumps({ "type": "debug", "msg": obj}), flush=True) + self.send({ "type": "debug", "msg": obj}) def sendEnd(self, overall, difficulties): - print(json.dumps({"overallScore": overall, "score": difficulties}), flush=True) + self.send({"overallScore": overall, "score": difficulties}) def sendError(self, message): - print(json.dumps({"error": f"Could not handle message {message}"}), flush=True) + self.send({"error": f"Could not handle message {message}"}) def sendScore(self, id, timingScore, timingInformation): - print(json.dumps({"id": id, "timingScore": timingScore, "timingInformation": timingInformation}), flush=True) + self.send({"id": id, "timingScore": timingScore, "timingInformation": timingInformation}) def gameLoop(self): while True: @@ -118,7 +121,7 @@ class Scorometer(): self.handleMessage(line.rstrip()) else: pass - self.sendEnd(0, {}) + self.sendEnd(self.score, {}) def main(): try: