abbastoof / transcendence

2 stars 3 forks source link

Set up game server on socket.io #30

Closed trsctr closed 1 month ago

trsctr commented 1 month ago

Branch Name: chore/030-setup-game-server-socketio

Description:

Configure the game server to run on plain Python and Socket.IO using eventlet instead of Django and Channels. Migrate the current game server code and refactor it to ensure all existing functionalities are preserved and improved. Address any errors encountered during the migration process. Additionally, configure socket connections for the frontend renderer to ensure seamless communication between the client and server.

Tasks:

  1. Setup Socket.IO Server:

    • [x] Install python-socketio and eventlet dependencies.
    • [x] Create a basic Socket.IO server instance.
    • [x] Configure CORS to allow connections from the frontend.
  2. Migrate Game Logic:

    • [x] Transfer game logic from the current Django/Channels setup to the new plain Python structure.
    • [x] Refactor game state management, player handling, and ball mechanics to work seamlessly with the new setup.
  3. WebSocket Communication:

    • [x] Implement WebSocket communication for real-time game updates.
    • [x] Ensure game state updates, player movements, and game events are correctly sent and received.
  4. Configure Frontend Socket Connections:

    • [x] Establish socket connections between the server and the frontend renderer.
    • [x] Ensure the frontend can send and receive real-time game updates.
    • [x] Test the socket connections to confirm data integrity and synchronization.
  5. Multithreading Implementation:

    • [ ] Modify the game loop to run on separate threads to handle multiple game sessions concurrently.
    • [ ] Ensure thread safety and efficient communication between threads.
  6. Error Handling and Logging:

    • [x] Add robust error handling to catch and log exceptions during gameplay.
    • [x] Ensure logs provide sufficient detail for debugging and performance monitoring.
  7. Testing and Debugging:

    • [x] Thoroughly test the migrated game server to identify and fix any issues.
    • [x] Perform load testing to ensure the server can handle multiple concurrent games.
  8. Documentation:

    • [x] Update the project documentation to reflect the new server setup.
    • [x] Include setup instructions, usage examples, and any relevant diagrams.
  9. Cleanup:

    • [x] Remove any obsolete code related to Django and Channels.
    • [x] Ensure the project structure is clean and organized.

Definition of Done:

Acceptance Criteria:

trsctr commented 1 month ago

Did not implement multithreading yet, seems async is doing things just fine for now, threading might not be necessary