mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
optimize broadcast to serialize once
This commit is contained in:
@@ -163,15 +163,17 @@ async def send_json_msgs(client: Client, msg: str):
|
||||
|
||||
|
||||
def broadcast_all(ctx: Context, msgs):
|
||||
msgs = json.dumps(msgs)
|
||||
for client in ctx.clients:
|
||||
if client.auth:
|
||||
asyncio.create_task(send_msgs(client, msgs))
|
||||
asyncio.create_task(send_json_msgs(client, msgs))
|
||||
|
||||
|
||||
def broadcast_team(ctx: Context, team, msgs):
|
||||
msgs = json.dumps(msgs)
|
||||
for client in ctx.clients:
|
||||
if client.auth and client.team == team:
|
||||
asyncio.create_task(send_msgs(client, msgs))
|
||||
asyncio.create_task(send_json_msgs(client, msgs))
|
||||
|
||||
def notify_all(ctx : Context, text):
|
||||
logging.info("Notice (all): %s" % text)
|
||||
|
Reference in New Issue
Block a user