this is how i bind ws to meteor.js webapp server, is there a way to do samething with yjs?
import { WebSocketServer } from 'ws'
const wss1 = new WebSocketServer({ noServer: true })
WebApp.httpServer.on('upgrade', function upgrade(request, socket, head) {
console.log(request.url)
if (request.url === '/hello') {
wss1.handleUpgrade(request, socket, head, function (ws) {
wss1.emit('connection', ws, request)
})
}
})
wss1.on('connection', function connection (ws) {
ws.on('error', console.error)
ws.on('message', function message(data) {
console.log('received: %s', data)
})
ws.send('something')
})
raine
#2
You can do a custom binding of your y-websocket server similar to the built-in server.
The important part is calling setupWSConnection
: