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

Auto-host mode #8

Open
delucis opened this issue Oct 11, 2021 · 0 comments
Open

Auto-host mode #8

delucis opened this issue Oct 11, 2021 · 0 comments

Comments

@delucis
Copy link
Member

delucis commented Oct 11, 2021

Using PeerJS’s 'unavailable-id' error type, it might be possible to automatically decide which client is the host.

  1. All clients would initially attempt to claim the host ID.

  2. If a client receives the 'unavailable-id' error, that indicates a peer has already taken the role of host and the client should attempt to connect to the existing host.

API could be P2P({ isHost: 'auto' }).

This has the advantage of the web app not needing to decide who hosts in advance. Just fire up the P2P transport and the first client to connect will host.

The disadvantage would likely be primarily for longer running games once #3 is implemented. With state persistence it would probably be desirable to have a static host. Some form of #4 could mitigate that: any client can host and all clients persist state.

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

No branches or pull requests

1 participant