Skip to content

Commit

Permalink
Fix FCH use
Browse files Browse the repository at this point in the history
  • Loading branch information
zjkmxy committed Nov 18, 2023
1 parent 2366ea3 commit 0021bf8
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/components/connect/ndn-testbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ export default function NdnTestbed(props: {
const [pinResolver, setPinResolver] = createSignal<Resolver>()

const onFch = async () => {
const position = await new Promise<GeolocationPosition | undefined>(
resolve => navigator.geolocation.getCurrentPosition(
pos => resolve(pos),
() => resolve(undefined)))
const fchRes = await fchQuery({
transport: 'wss',
position: [
position?.coords.longitude ?? 0,
position?.coords.latitude ?? 0,
]
})
const url = new URL(fchRes.routers[0].connect)
setHost(url.host)
try {
const fchRes = await fchQuery({
transport: 'wss',
network: "ndn",
})
if (fchRes.routers.length > 0) {
const url = new URL(fchRes.routers[0].connect)
setHost(url.host)
}
} catch {
console.error('FCH server is down.')
}
}

const onInputPin = () => {
Expand Down

0 comments on commit 0021bf8

Please sign in to comment.