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

support for multiple tab connection #647

Open
Jaysojitra13 opened this issue Apr 10, 2020 · 5 comments
Open

support for multiple tab connection #647

Jaysojitra13 opened this issue Apr 10, 2020 · 5 comments
Labels
client related to peerjs client

Comments

@Jaysojitra13
Copy link

When I establish a connection using perrjs in one tab of chrome, it's working properly. But when I open a new tab, it again tries to make a connection. So it throws an error like "ID_IS_TAKEN".

Usecase is when I open multiple tabs, the connection should remain the same across all the tabs.

Is there any way to prevent this?

@jrowny
Copy link

jrowny commented Apr 19, 2020

Each tab will need a unique ID because they'll need a unique connection to each other. Each tab would just be another peer. There's no way to keep the same connection across tabs.

@Jaysojitra13
Copy link
Author

Thank you @jrowny for the update.

@quentincaffeino
Copy link

@Jaysojitra13, I think Workers could help you with that. At least that's an optimization I'm planning to do sometime with my project.

@Jaysojitra13
Copy link
Author

@quentincaffeino , I also tried with the sharedWorkers. But the problem is I'm not able to pass the object of peerjs itself.

Here is the reference, https://blog.arnellebalane.com/sending-data-across-different-browser-tabs-6225daac93ec.

Let me know if you found any solution.

@quentincaffeino
Copy link

quentincaffeino commented Apr 20, 2020

@Jaysojitra13, And you won't be able because they don't share any mutual memory and all connection between worker and client is going through binary data channel.

I don't understand why would you want to pass peerjs instance.

The solution is to use messaging between worker and a client.
I'd suggest using Workbox and Workbox-Client with ServiceWorkers cause it might make your life easier (at least it made mine).

@irgalamarr irgalamarr added the client related to peerjs client label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client related to peerjs client
Projects
None yet
Development

No branches or pull requests

4 participants