usar API de metered.ca
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fixes #22
This commit is contained in:
parent
cd505ab677
commit
866fbfd7ec
2 changed files with 22 additions and 21 deletions
|
@ -5,6 +5,12 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
<link rel="manifest" href="/manifest.webmanifest" />
|
||||||
<link rel="icon" href="/edit-2-outline.svg" />
|
<link rel="icon" href="/edit-2-outline.svg" />
|
||||||
|
<link
|
||||||
|
rel="preload"
|
||||||
|
href="https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574"
|
||||||
|
as="fetch"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
/>
|
||||||
<title>Schreiben</title>
|
<title>Schreiben</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -24,6 +24,10 @@ export function generateNewWorld(): WorldIdentifier {
|
||||||
// cache the previous doc and return that instead
|
// cache the previous doc and return that instead
|
||||||
let worldYCache: { [key: string]: WorldY } = {};
|
let worldYCache: { [key: string]: WorldY } = {};
|
||||||
|
|
||||||
|
const credsReq = fetch(
|
||||||
|
"https://nulo.metered.live/api/v1/turn/credentials?apiKey=205de2914a8564e2efa19a7d7f299a95e574"
|
||||||
|
).then((res) => res.json());
|
||||||
|
|
||||||
export function getWorldY(world: WorldIdentifier): WorldY {
|
export function getWorldY(world: WorldIdentifier): WorldY {
|
||||||
if (worldYCache[world.room]) return worldYCache[world.room];
|
if (worldYCache[world.room]) return worldYCache[world.room];
|
||||||
const ydoc = new Y.Doc();
|
const ydoc = new Y.Doc();
|
||||||
|
@ -36,27 +40,18 @@ export function getWorldY(world: WorldIdentifier): WorldY {
|
||||||
// "wss://y-webrtc-signaling-eu.herokuapp.com",
|
// "wss://y-webrtc-signaling-eu.herokuapp.com",
|
||||||
// "wss://y-webrtc-signaling-us.herokuapp.com",
|
// "wss://y-webrtc-signaling-us.herokuapp.com",
|
||||||
],
|
],
|
||||||
peerOpts: {
|
});
|
||||||
config: {
|
credsReq.then((iceServers) => {
|
||||||
iceServers: [
|
// change the default for future connections
|
||||||
// { urls: "stun:stun.l.google.com:19302" },
|
provider.peerOpts.config = { iceServers };
|
||||||
// { urls: "stun:global.stun.twilio.com:3478?transport=udp" },
|
if (!provider.room?.webrtcConns) return;
|
||||||
{
|
// change the configuration in current connections
|
||||||
urls: "stun:relay.metered.ca:80",
|
for (const conn of provider.room?.webrtcConns?.values()) {
|
||||||
},
|
const pc: RTCPeerConnection = conn.peer._pc;
|
||||||
{
|
pc.setConfiguration({
|
||||||
urls: "turn:relay.metered.ca:443",
|
iceServers,
|
||||||
username: "7aec233ea46fa835147308ae",
|
});
|
||||||
credential: "c0eTB5pqj9vOxhii",
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
urls: "turn:relay.metered.ca:443?transport=tcp",
|
|
||||||
username: "7aec233ea46fa835147308ae",
|
|
||||||
credential: "c0eTB5pqj9vOxhii",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const idbProvider = new IndexeddbPersistence(world.room, ydoc);
|
const idbProvider = new IndexeddbPersistence(world.room, ydoc);
|
||||||
const worldY = { ydoc, webrtcProvider: provider };
|
const worldY = { ydoc, webrtcProvider: provider };
|
||||||
|
|
Loading…
Reference in a new issue