Closed jimhendy closed 1 month ago
Hey @jimhendy, I don't understand what the current version of this package doesn't allow you to do. Have you checked some of the examples?
I also built a chatroom example with firestore here https://github.com/RenaudLN/dash-firestore-chat for a bit more comprehensive use.
Oops, apologies! I hadn't realised this was already possible. Extra thanks then for this great library!
Hi @RenaudLN,
Thanks so much for your great work for this component, I have been thinking about mixing
dash
andsocketio
for a while but am not smart enough to understand thereact
side.Would you consider some changes to the component to allow triggering of callbacks using the socket component?
I would like to be able to use
flask-socketio
's ability to emit to a subset of connectted users (rooms) to build multiplayer games usingdash
. This requires triggering callbacks to both receive and emit messages from the client'sdash
application.I don't intend this PR to be merged as it breaks existing functionality, I just wanted to present my ideas as code. My proposal can be demoed using the usage_server.py and usage_client.py scripts run at the same time.
A few details that might seem strange:
ws-event
) in place of whitelisting relevant events. Thereact
code then extracts the details from the body to fire callbacks using thedata-...
attributes.react
only triggersdash
callbacks on changes. Therefore, on messages sent form the client I add a uuid to ensure a unique message and on incoming messages from the server I overwrite the state attribute with null before actually setting with the value.