Tuesday, July 11, 2023

Django Channels with Queue (Lobby) Manager

Hello dear Community!

I need help with Django channels and Websockets (i guess) for an application I am building. The project is online Chess game with Django as a backend and vanilla JavaScript (ajax, jQuey and some bootstrap). We are using custom chess engine written in python.  

Previously we succesfully built flask application with single view to play chess game hand-to-hand. I wanted to improve our backend and introduce game lobbies - general online. This would also be a great practice and learning. Or so I thought.
I have gone through the Django Channels docs and followed simple tutorial to create a chat application - more or less the concept is understood. 

My goal is to create a lobby like system as in other online games:
  • User has to be autorized and only authorized users can do anything
  • You can click on "New game" - it will put you in waiting or lobby room. If you match with another user who has right conditions (for now: oppotise pieces color) - you two are put in a game and game starts
  • If there are no games available after some timeout - it will through you out to main screen and ask to "Try later"
I have some ideas and questions, but I would like to hear how this idea can be coded and what would be the right plan for realisation first. Maybe my questions and ideas are completely irrelevant.

P.S.: We are using custom written chess engine in Python via OOP. It worked very poorly in Flask by just creating Game object from a class in View function. This you should not do... What would be the best practice to actually access it and when we should create it? I have seen examples with TicTacToe game and logic stored as a model, but i think it would be very heavy on database....

Looking forward for replies :) 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ca46cb38-d3a7-4d24-b5f2-b7fda612f445n%40googlegroups.com.

No comments:

Post a Comment