How to restrict channels based on database constraint?
I suppose this counts as a support request.
I would like to use WS4REDIS_ALLOWED_CHANNELS to restrict the clients which can connect to a channel. The users' eligibility for the channel is based on permissions stored in the database. But the documentation for WS4REDIS_ALLOWED_CHANNELS states I can't use the DB:
Remember that this function is not allowed to perform any blocking requests, such as accessing the
database!
So what should I do? Can I return something like a promise? Or somehow else do async database queries?
You should add the permission checks to the Django-Loop and then store them in Redis. This has some benefits: a) they expire themselves b) in the WS-loop you look up for that permission in Redis, using the session-id supplied by the client.
that should be rather easy to implement by inheriting from the subscriber classes.