Skip to content

Commit

Permalink
wip: custom experimental cloudflare rtc
Browse files Browse the repository at this point in the history
  • Loading branch information
chase-moskal committed Nov 9, 2024
1 parent 98f3752 commit 06d3669
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions s/demo/logic/situations/custom-rtc-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

// export const customRtcConfig = (): RTCPeerConnection => ({
//
// })
export const customRtcConfig = (): RTCConfiguration => ({
"iceServers": [{
"urls": [
"stun:stun.cloudflare.com:3478",
"turn:turn.cloudflare.com:3478?transport=udp",
"turn:turn.cloudflare.com:3478?transport=tcp",
"turns:turn.cloudflare.com:5349?transport=tcp",
],
"username":"g01f61887a5c954b0421992d6a74f8328ab095946726088e3018787be35da76a",
"credential":"3988c6fe102ae5b7d61bd73ec74661f67107a1db0518f8039a36a4be53235bf3"
}],
})

2 changes: 2 additions & 0 deletions s/demo/logic/situations/hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Id} from "../../../tools/id.js"
import {Hosted} from "../../../browser/host.js"
import {Stats} from "../../../signaller/types.js"
import {Sparrow} from "../../../browser/sparrow.js"
import {customRtcConfig} from "./custom-rtc-config.js"
import {Lobby, Person, UserDetails} from "../types.js"
import {Connection, StdCable} from "../../../browser/types.js"

Expand All @@ -24,6 +25,7 @@ export class HostingSituation {
const onClosed = pubsub()

const hosted = await Sparrow.host<StdCable>({
rtcConfig: customRtcConfig(),
url,
allow: async() => true,
closed: () => {
Expand Down
4 changes: 3 additions & 1 deletion s/demo/logic/situations/joiner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import {signal} from "@benev/slate"
import {Lobby} from "../types.js"
import {Joined} from "../../../browser/join.js"
import {Sparrow} from "../../../browser/sparrow.js"
import {StdCable} from "../../../browser/types.js"
import {Sparrow} from "../../../browser/sparrow.js"
import {customRtcConfig} from "./custom-rtc-config.js"

export class JoinerSituation {
static async start(url: string, invite: string, disconnected: () => void) {
const joined = await Sparrow.join<StdCable>({
url,
rtcConfig: customRtcConfig(),
invite,
disconnected,
})
Expand Down

0 comments on commit 06d3669

Please sign in to comment.