I’m having few doubts regarding setting up y-codemiror: for my Realtime Collaborative Code Editor Project
Do I need to setup y-websocket use to setup y-codemirror ?
I’m using socket.io in server. Do I need to make changes in server ?
I’ve tried implementing y-codemirror . I’m getting desired Code Changes are reflecting on all client in room. And on server side new socket connection is getting made but
on console.log i’m getting “websocket connection to 'ws //localhost:5000 failed error”//line 17 on Editor.js
Since i’m not able to link my Editor.js and Server.js code here. I’ve shared it in comments
y-codemirror will work with any YJS provider, including but not limited to y-websocket. The example provided on the y-codemirror repo uses y-webrtc.
If you are using y-websocket, your WebsocketProvider on the client has to be pointed towards a y-websocket server (not just any socket.io server).
The easy, no-code approach is to launch a y-websocket server is to run HOST=localhost PORT=1234 npx y-websocket right from your terminal. The source code for this built-in y-websocket server (below) reveals how you could integrate it into an existing http server. You just need to upgrade the connection and call setupWSConnection. However, I am not sure if you can run it on the same port as an existing socket.io server.