-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
websockets #72
base: main
Are you sure you want to change the base?
websockets #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This couples Wisp very tightly to Mist, which it carefully does not do so far. We'll need to decouple it, I've left some notes inline.
I've now created a pure wisp public api for this which mostly wraps the mist types. Docs (and likely type names/api) still need work but wanted to verify if the approach is more suitable for wisp before attempting to polish things. Hopefully the Socket type would allow wrapping various connection types that may be required by potentially different backends as appropriate? Let me know if I'm on the right track or missing a beat. Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! I like how this is coming along.
There's still some dependency of Mist that needs to be removed. Soon the Mist specific code will be moved to another package, so there can be no dependency here.
Another problem to solve is how do we make it so a Wisp application can only upgrade to a websocket connection if the webserver being used supports it? For example, Elli and CGI don't support websockets, so the programmer must not have the ability to construct a websocket response in those cases. Perhaps it could be that there's some secondary capability value that gets passed in by websocket capable servers, and that is need to upgrade within the application. Whatever the solution the same pattern will need to be usable for server sent events too.
Another thing is how do we write tests for websocket using applications too.
Is there any other problems to solve or other considerations?
Okay. Had a big stab at moving all the mist stuff into a separate module. I've fully removed the import mist from the main wisp.gleam file. Websockets are also now implemented with a reference example in the test file. I've had to make a couple things in the wisp.gleam file public that I'm not sure we want to keep that way (mostly around Everything needs a tidy, documentation and the test cases fleshed out but hopefully it's looking more like how we want it to be ^^? Definitely not finished working on it (want to try dump mist from internal somehow) but keen to take any feedback generally at this stage! |
Okay! I think I'm feeling happy with the general api design and split of things now and was thinking of moving on to docs. I was thinking of creating a websocket error type within wisp as well for when |
note: the client doesn't seem to return any responses for some reason when running under gleeunit
… to be hidden from docs
left to do:
done? |
Here's a first pass, scrappy implementation of mists websockets into wisp. #10
Still figuring out if there's a better way to do this and discussing with rawhat a little on approaches.
This currently works though. Feedback on approach most welcome.
Option was only added due to the test stuff, not sure how do deal with that yet but maybe that's solving the wrong problem.