Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this example with y-webrtc? #15

Open
yogesh-sirsat opened this issue Mar 5, 2024 · 0 comments
Open

How to use this example with y-webrtc? #15

yogesh-sirsat opened this issue Mar 5, 2024 · 0 comments

Comments

@yogesh-sirsat
Copy link

I'm having difficulty to use this example with y-webrtc, even though I suppose the changes should be not much looking at the code of this example.

I changed this line with webrtcProvider.

room: new WebsocketProvider(hostUrl, roomId, yDoc, { connect: true }),

and removed this lines, since I guessed this lines has to do with websocket provider only.

function handleStatusChange({
status,
}: {
status: 'disconnected' | 'connected'
}) {
// If we're disconnected, set the store status to 'synced-remote' and the connection status to 'offline'
if (status === 'disconnected') {
setStoreWithStatus({
store,
status: 'synced-remote',
connectionStatus: 'offline',
})
return
}
room.off('synced', handleSync)
if (status === 'connected') {
if (hasConnectedBefore) return
hasConnectedBefore = true
room.on('synced', handleSync)
unsubs.push(() => room.off('synced', handleSync))
}
}
room.on('status', handleStatusChange)
unsubs.push(() => room.off('status', handleStatusChange))

and just called handleSync function, at the end of useEffect().

but it seems to be not working, I can't see remote changes only local changed on tldraw canvas, and In browser console I'm getting this error:
error.js:12 Uncaught (in promise) Error: A Yjs Doc connected to room "example17" already exists!

I guess its creating duplicate rooms with same id, but I'm not sure why and which change is causing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant