basic matchmaking flow
This commit is contained in:
12
game_flow.py
12
game_flow.py
@@ -118,6 +118,18 @@ class PlayerWebSocketHandler(WebSocketHandler):
|
||||
print(f"[{self.label}] UNKNOWN OPCODE {op}: {payload}")
|
||||
|
||||
# ---------- Match Helpers ----------
|
||||
def rpc_find_match(self) -> str:
|
||||
"""Call rpc_find_match and return Nakama match_id."""
|
||||
r = requests.post(
|
||||
f"{HOST}/v2/rpc/rpc_find_match",
|
||||
headers={"Authorization": f"Bearer {self.token}"},
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
# RPC returns {"payload": "<json string>"}
|
||||
payload = json.loads(r.json()["payload"])
|
||||
return payload["match_id"]
|
||||
|
||||
async def create_match(self) -> str:
|
||||
await self.ws.send(json.dumps({"match_create": {}}))
|
||||
msg = json.loads(await self.ws.recv())
|
||||
|
||||
Reference in New Issue
Block a user