dmotz / trystero

✨🤝✨ Build instant multiplayer webapps, no server required — Magic WebRTC matchmaking over BitTorrent, Nostr, MQTT, IPFS, Supabase, and Firebase
https://oxism.com/trystero
MIT License
1.14k stars 85 forks source link

webRTC matchmaking URI scheme proposal #brainstorm #82

Open coderofsalvation opened 1 month ago

coderofsalvation commented 1 month ago

In xrfragment.org buttons have link-values which trigger a trystero connection:

By using URI's, the content can prime the trystero-configuration popup (presets). This enables content to 'bring their own network', instead of apps locking users into theirs.

With that in mind, the eventual protocol is merely used as a commons for Peer Discovery. Afterwards, the 'app' decides how to manage data between peers via WebRTC protocol right? (it seems we're using 1% of the protocol, just the frontdoor to look who's inside).

Since trystero is quite a new protocol-agnostic concept, and imaging that other services (XMPP, SIP, IRC,Matrix) could be added as well, how crazy is the idea of a flexible webRTC matchmaking URI scheme:

coderofsalvation commented 1 month ago

UPDATE

actually the magnet URI RFC already is exactly that for webtorrent, and the other protocols also have their URI specs.
Is it an idea to let trystero-instance (user A) output an URL which can configure the protocol of another trystero-instance (user B) on the fly?

idea: url config key

const room = joinRoom({
  appId: 'san_narciso_3d', 
  // optional, in case enduser received a trystero SHARE URL:
  url: ""magnet:?xt=urn:bti:1234567890abcdef1234567890abcdef12345678&dn=MYROOMID"
})

/*
 * // trystero can infer protocol from URL
 * let url = new URL(config.url)
 * if( url.protocol == 'magnet:' && url.searchParams.get('dn') ){ // detect webtorrent
 *    room.id = url.searchParams.get('dn')
 * }
 * if( url.protocol == 'ipfs:' ){   .... }
 * opts.URL = url
 */

// this url can be shared:
console.log( room.url )
// 'magnet:?xt=urn:bti:1234567890abcdef1234567890abcdef12345678&dn=MYROOMID'

console.log( room.URL.protocol )
// 'webtorrent'
// in case of ipfs, it would output ipfs://.....   e.g.

is this an interesting way of allowing trystero to share protocol-specific rooms via URI's ? (that way, a trystero app-developer doesn't have to bet on one horse during pageload anymore)