wasp
wasp copied to clipboard
Enable using the Websocket server inside of server-side code outside of the Websocket init function
Right now, the initialized server is not exposed or documented for the user to use.
For example, when somebody likes a post, it might trigger something and a notification is sent over the socket.
Relevant Discord convo, we had user asking for this: https://discord.com/channels/686873244791210014/1208036265308586034/1208060190856056932 .
@Martinsos Any update on this? What would be the best way to have the server send web socket events to update the client, on download status for example, outside of the webSocket fn? (Also the Discord link has expired and can't join discord :(( )
@Martinsos Any update on this? What would be the best way to have the server send web socket events to update the client, on download status for example, outside of the webSocket fn? (Also the Discord link has expired and can't join discord :(( )
@infomiho knows the best about websockets in Wasp so will be able to provide some clarity!
This is our perma-invite, it works for me and should work well: https://discord.gg/rzdnErX !
Small update here, for visibility:
The current work around is to:
- Create a global function, that is initialized and defined in your webSocketFn
- Export this global function (ie, ioInstance)
- Import the ioInstance in other places in your backend server where you need access to the instance.
I believe they are working on making it more built in to the Wasp Experience :)