First pass of working websockets integration#19
Open
goldenapples wants to merge 7 commits intomasterfrom
Open
Conversation
Adds Flask-SocketIO as a websocket server, and redux-socket.io as a client-side middleware. This seems to make the connection properly, and as far as I can tell the message is emitted properly with the gunicorn server used on heroku, but I can't make it work locally. Leaving this for now to work on something that I actually know how to do.
When a new message comes in, it will emitted to all connected listeners via websockets. This then dispatches a redux action to update the current application state for all logged-in admin users/ Not much else happening here yet, but this part is functional at least.
Because the development server has to run as a multi-threaded app in
order to server the webhooks now, it's really hard to shut it down when
done working with it. This little snippet adds an endpoint which you can
post to and shut it down.
http post :5000/api/shutdown
Should go without saying that this is just a hack for development and
needs to be removed before this ever goes to production.
In order for this reducer to put it's data at the same place in the store as the other message-related reducers, it should be in the same module (this also makes good sense from a code organization standpoint as well).
Just a hint of how this UI could work in practice. The message comes in with an "unread" flag on it, and we count the unread flags in each message or event to show a badge indicatin that there's new activity to check out there.
Also adds a basic nav footer with badge notification when unread messages come in to one of these locations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gets a socket.io server (through Flask-SocketIO) and a websocket redux action working.
When a new message comes in, it will be emitted to all connected listeners via websockets. This then dispatches a redux action to update the current application state for all logged-in admin users/
Not much else happening here yet, but this part is functional at least.
Note that the basic development server won't really handle websockets well; for now you'll have to use the
--threadedoption to run the development server:python manage.py runserver --threaded.