WebSocket with socket.io?

Hello,

I’m trying to figure out how to use the websockets op in cables. I have used socket.io previously to create websocket like connections and I know what it’s possible to use it to create websockets. Does anyone have a simple example of using socketio to send data into cables? I have tried everything I can think of and can’t seem to get it to work.

A non socketio example with vanilla websockets would be ok too. I just want to be able to hook up cables to another project I’m working on without having to export a new version every time there’ s a change.

hey,

as far as i understand your question you’d only need the serverside of socket.io to have
a websocket-server to talk to. here is some general information on the websocket ops in cables
and an example:



you basically need to point this to your socket.io server and then work form there.

Thanks,

What I was really interested here was a workflow for integrating cables in with a larger project, which I found had already been documented here.

Hi,

socket.io is a protocol, that can work over websockets, but often uses fallbacks etc.
so it is not compatible with our websocket ops.

i don’t know much about socket io and the message protocol, but it should be quite easy to implement.

anyway,…

i put togegther a basic example:


and https://cables.gl/p/5da62a2c45257b4cca21898a

let me know if you have any questions

1 Like