Skip to content

Conversation

@matheus23
Copy link
Member

@matheus23 matheus23 commented Feb 26, 2025

Description

Uses window.navigator.onLine and window.addEventListener("online", ...) and friends to listen for network changes.

Notes & open questions

I tested this manually in firefox, chromium and gnome's WebKit-based browser.
I'm not sure how easy it would be to set up automated testing for this :S
Pretty hard. I've at least made sure there's a node.js smoke test for this, so that using the API doesn't fail, even if the underlying navigator.onLine or "online"/"offline" event listener APIs don't exist.
Even if this were run in a browser, it'd be hard to trigger online/offline.

The code generally falls back to not doing monitoring when the platform doesn't support it (e.g. node.js). In that case, you just won't get any events.

Change checklist

  • Self-review.
  • Test

@matheus23 matheus23 self-assigned this Feb 26, 2025
@github-actions
Copy link

github-actions bot commented Feb 26, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/net-tools/pr/14/docs/iroh_gossip/

Last updated: 2025-03-04T09:32:15Z

Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little note, otherwise lgtm

@matheus23 matheus23 merged commit acc127c into main Mar 4, 2025
25 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Mar 4, 2025
@matheus23 matheus23 deleted the matheus23/netwatch-wasm branch March 4, 2025 09:40
github-merge-queue bot pushed a commit to n0-computer/iroh that referenced this pull request Mar 4, 2025
…ure in Wasm (#3206)

## Description

- Enables the `netwatch` dependency in Wasm
- Un-cfg-s the `netwatch::netmon::Monitor` in `magicsock::Actor`
- Enables the `metrics` feature for Wasm by depending on a newer
iroh-metrics
- Minor: We go back to using `netwatch::ip::is_unicast_link_local`, as
we can depend on that in Wasm again now.

## Notes & open questions

There's some dependencies:
- [x] Needs #3203 to be merged first
- [x] Depends on n0-computer/net-tools#14 being
merged
- [x] And released
- [x] Depends on a new release of the `iroh-metrics` main branch (I.e.
n0-computer/iroh-metrics#11 being released)

Closes #3195

## Change checklist

- [x] Self-review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants