Skip to content

refactor(host): the streaming core is a library too - #23

Merged
th3r-dev merged 1 commit into
devfrom
feat/host-lib
Nov 11, 2026
Merged

th3r-dev merged 1 commit into
devfrom
feat/host-lib

Conversation

@th3r-dev

Copy link
Copy Markdown
Owner

This is step 1 of letting the tablet share its screen to the Mac. The Android app needs the host's sessions, signaling and pairing. This PR changes nothing on the Mac.

What changed

  • crates/host is now a library and a binary.
    • lib.rs exports session, signaling, pairing, screens, timing, probe_page, config and platform.
    • It adds start(HostOptions) -> Host, which holds the wiring main.rs used to do inline: the session thread, the pairing store, the signaling listener and web port, and the address to show.
    • No files moved, so the asset paths and tests stay where they were.
  • main.rs keeps what is the Mac's: flags, app paths, the menu bar, the pairing-code dialog, the updater and the viewer.
  • Receivers are told what kind of host this is. Messages like "Pair this device with the Mac first" now take the kind from HostOptions.kind; the Mac passes "Mac". The Android host will pass "tablet".
  • A busy port still shows the "already running" dialog. start() marks that error with PortInUse.

The macOS-only dependencies were already target-gated, so building for Android only pulls in the cross-platform crates.

Testing

  • cargo test: all 72 pass (46 host, 26 proto), the same as on dev.
  • cargo check -p mullion-host --lib --target aarch64-linux-android builds with no errors or warnings.
  • Ran the binary on port 47201:
    • /hello answers;
    • an unpaired device is told "Pair this device with the Mac first.";
    • a second copy on the same port fails with the same port-in-use message as before.
  • Not done: I didn't stream to a browser by hand. The capture and session paths have no code changes, and the existing signaling test still covers pairing plus a sealed offer and answer.

Next: PR 2, the Android host ("Share this screen").

The Android app will share its own screen (a Mac shows it), so it needs the
host's sessions, signaling and pairing. crates/host is now lib + bin: lib.rs
exports session, signaling, pairing, screens, timing, probe_page, config and
platform, plus start(HostOptions) -> Host with the wiring main.rs did inline
(session thread, pairing store, signaling listener and web port, the address
to show). main.rs keeps what is the Mac's: flags, AppPaths, the menu bar, the
code dialog, the updater and the viewer.

Signaling's messages to receivers name the host's kind ("Pair this device
with the Mac first") from HostOptions.kind instead of a fixed "Mac".

No behaviour change on the Mac. A taken port is still the "already running"
dialog: start() marks that error with PortInUse.

Checked: 72 tests pass; the lib builds for aarch64-linux-android; the binary
serves /hello and refuses an unpaired device as before.
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@th3r-dev
th3r-dev merged commit 2415c72 into dev Nov 11, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant