Skip to content

First pass of working websockets integration#19

Open
goldenapples wants to merge 7 commits intomasterfrom
add-socketio-connector
Open

First pass of working websockets integration#19
goldenapples wants to merge 7 commits intomasterfrom
add-socketio-connector

Conversation

@goldenapples
Copy link
Contributor

@goldenapples goldenapples commented Sep 6, 2017

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 --threaded option to run the development server: python manage.py runserver --threaded.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant