jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
896 stars 222 forks source link

Add Facility Management? #167

Closed pkkid closed 8 years ago

pkkid commented 8 years ago

I wanted to open a discussion on facility management in this app. Essentially I see some limitations in how this app can be useful for more than 1 type of websocket unless all the application logic sits on the client side (javascript) code. More to the point:

The final bullet point being my biggest motivation here. I read a bit where other users of this app hinted at this limitation and were quickly met with a response such as you shouldn't need to do that; hinting because concurrent Python code is tricky, and most server-side logic will be blocking calls and thats bad for websockets running on gevent. I agree concurrent Python code is tricky, and I admit I do not fully understand it myself. But I also think this app shouldn't hard-prevent us from add anything in (even though we may shoot ourselves in the foot).

I'd like to propose the following; and I'm totally willing to contribute the code, but I also somewhat fear this is a big change to the core values you had when writing this app and the contribution may be faced with opposition (hence this discussion).

A quick code example to show what I was thinking..

WS4REDIS_FACILITIES = (
    'chat': 'mysite.apps.chat.facility.ChatFacility',
    ...
)
class ChatFacility(BaseFacility):

    def __init__(self, websocket, redis, user):
        pass

    def on_open(self):
        pass

    def on_message(self, message):
        pass

    def on_close(self):
        pass

    @classmethod
    def allowed_channels(request, channels):
        return channels