Skip to content

Commit

Permalink
Merge pull request #9 from anitejb/feature/multiplayer-2
Browse files Browse the repository at this point in the history
Multiplayer Support
  • Loading branch information
chiragrank authored Dec 14, 2021
2 parents c7ff8f3 + 2a6a3ec commit 3095a50
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import concurrent.futures
import datetime
import json
import os
import sys
from hashlib import sha1
Expand All @@ -15,7 +16,7 @@
from rich.console import Console

ping_freq, ping_wait = 25, 60
player_limit = 1
player_limit = 2


console = Console()
Expand Down Expand Up @@ -52,7 +53,7 @@

executor = concurrent.futures.ThreadPoolExecutor(max_workers=20)

cred = credentials.Certificate(eval(os.environ["FIREBASE_AUTH"]))
cred = credentials.Certificate(json.loads(os.environ["FIREBASE_AUTH"]))
initialize_app(cred, {"databaseURL": os.environ["FIREBASE_URL"]})
ref = db.reference("/")

Expand Down Expand Up @@ -139,8 +140,14 @@ async def rescue_attempt_handler(sid, message):
loop.run_in_executor(executor, save_data, sid, message)


@sio.on("rescue_success")
async def rescue_success_handler(sid, message):
@sio.on("rescue")
async def rescue_handler(sid, message):
console.print(message, sid, style="bold blue")
await sio.emit("rescue_success", message, room=message["rm_id"])


@sio.on("rescue_displayed")
async def rescue_displayed_handler(sid, message):
console.print(message, sid, style="bold blue")
loop = asyncio.get_event_loop()
loop.run_in_executor(executor, save_data, sid, message)
Expand Down

0 comments on commit 3095a50

Please sign in to comment.