Closed funkybunky closed 8 years ago
I haven't ported this library to 0.17 because there's an official websockets library now. The API looks different but that's because the signals and mailboxes that this library depends on aren't present in 0.17. So, any update here would require a complete rework of the API and new native code.
Please give the official package a try and let me know if you encounter problems using a websocket client with a socket.io server.
Thanks for your response. I actually tried the official websockets library, but I couldn't establish a connection between client and server (node with socket.io). But I guess I have to read up on ports first in order to integrate the socket.io client with elm..;) If I need help with that, I'll ask in slack. This issue doesn't seem to be the right place for a guide on how to wire things up.
Okay! The websocket package exposes Sub
and Cmd
which you need to use with Html.App.program
. Just creating them won't actually do anything.
Hm, user "kbsymanz" on the elm slack help channel said that the official new socket package is not suitable for connecting to socket.io, if I understood correctly. Quote: "If you use a Socket.io client external to the Elm app on the client, you can pass data in through Elm ports but you would not use the Elm Websocket module. That module is for websockets without the Socket.io client being involved."
From what I gather from these questions, that's correct (and I was misinformed). You won't be able to communicate with a socket.io server using a standard websocket client.
The slack user is correct, you can do it with ports. Indeed, that's what you have to do. But ideally one could wrap the very basics of a socket.io client with the exact same interface as the official websockets library.
But, in addition to being a lot of work, my native whitelisting was removed so I can't publish any more updates.
This library began as "I want bidirectional realtime communication between client and server", without really caring how it was done. Normal websockets (a web standard, not some bloke's library) probably suffice for this. But if you've got a Node server with socket.io pretty firmly entrenched, then it's a different story.
What a pity that we don't have an updated lib for elm 0.17!
I just tried official websockets lib an it sucks.
Now I will try to do it by port, made ELM not so good for me.
@mgold Thanks for this lib!
I got the "Unable to find a set of packages that will work with your constraints." error when trying to install this package into an existing 0.17 project. Just tried to port this package using this guide, but then ran into more difficult porting issues related to native JS code. After some research I found out about the somewhat vague situation about Native code here and here. Being a complete beginner to elm, I'm somewhat scared away now. Do you see a point in porting this lib to 0.17? What are your thoughts on this?