I’m curious as to what, who and how many people are doing things with web-sockets in Purescript, so i thought i’d make a thread here for that.
I have PureScript app that i’m working on which used to be entirely browser-based and is now going to be partly a NodeJS part and a smaller browser app. Up til now i’ve found websockets-simple to be sufficient to my needs but altho’ it does have some code to enable it to work in both browser and NodeJS modes, it doesn’t do server sockets.
Under the hood websockets-simple uses web-socket but i don’t see anything like new WebSocket.Server({port: nnnnn} in that library either, so i’m wondering, first of all, is anybody at all creating server sockets in their PureScript NodeJS apps?
And, secondly, i’m interested to hear what libraries people are using, recommending, not-recommending etc
AFAICT there’s no lib in the purescript ecosystem that wraps that sort of usage?
(trivially easy to wrap in FFI, i know, but by the same token, pretty easy to add to an existing PureScript web-socket library if there’s one that’s in common use)
purescript-web-socket is bindings to the W3C spec. All web libraries are bindings to some web platform spec, and not to libraries specifically. WebSocket.Server is not a web spec, and is just something that the ws library happens to implement.
I have no idea if there’s enough there to implement a server. You’d likely still need to glue things together with node-http, which is what I’m assuming WebSocket.Server is doing.
I believe that document is just explaining the actual protocol, if one were to implement a WebSocket server. I don’t think the web platform contains anything to ease writing a server.
It’s fine with me if just wrapping that Node library is the answer, i think. I think there’d still be value in a PR to websocket-simple to provide that wrapper to a PureScript programmer tho - so i think i’ll modify the library locally and offer that to the author if it works well enough.