Skip to content

Commit

Permalink
sending default game settings to connected clients
Browse files Browse the repository at this point in the history
  • Loading branch information
EdionHida authored Aug 26, 2024
1 parent 3e55fdd commit de5d8fb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Game_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ def print_active_games():
@sio.event
async def connect(sid, environ):
logging.info(f'Client connected: {sid}, Path: {environ.get("PATH_INFO")}')

json_data = {
"type": "game_defaults",
"PADDLE_WIDTH": PADDLE_WIDTH,
"PADDLE_DEPTH": PADDLE_DEPTH,
"BALL_RADIUS": BALL_RADIUS,
"BALL_SPEED": BALL_SPEED,
"PADDLE_SPEED": PADDLE_SPEED
}

for sid in self.sids:
await sio.emit('game_defaults', json_data, room=sid)

# Event handler for disconnections
# This function is called when a client disconnects from the server
Expand Down

0 comments on commit de5d8fb

Please sign in to comment.