Skip to content

Commit

Permalink
feat: use UDP to publish/listen for speaker notes (#419)
Browse files Browse the repository at this point in the history
This is a followup to #389 that uses UDP sockets and loopback broadcast
addresses to publish and listen for speaker notes. The previous solution
using `iceoryx2` was using shared memory to communicate between
different `presenterm` instances. This is fine but was causing a couple
of issues:

* When trying to compile presenterm in a clean system I found I needed
libclang (?) to build it. I'm not sure what transitive dependency needs
this but I don't really want to deal with having builds that require
having external libraries installed for it to work. e.g. this means we'd
have to do something about the CI as it will likely fail to build the
release artifacts as it is.
* This was pulling in roughly ~60 extra dependencies. I like to be
conservative with dependencies and while I'd be okay with pulling this
many if it really solved a problem that would be annoying to solve
otherwise, I think this is not the case.
* Not an issue right now but the events sent were limited to statically
allocated pieces of memory (e.g. no `Vec`s) which could cause future
evolutions of this solution to require hacky workarounds.

This new solution instead uses JSON over UDP sockets. Note that nothing
internally in how speaker notes are parsed/managed has changed, it's
just the communication protocol that did. This works like this:

* The publisher binds a UDP port to a random port and sends events to a
broadcast address on the loopback interface (e.g. `127.255.255.255:<some
port>`).
* Listeners will bind to that same broadcast address using a non
blocking socket and will listen for events as usual. Listeners use
`SO_REUSEADDR` to allow multiple listeners on the same port as otherwise
each packet goes to a single listener.

Events sent contain the full presentation path so this allows having
multiple publishers and listeners using different presentations but
listening on the same port. This is the equivalent of the service name
we had before.

As part of this I also changed the CLI parameters to be
`--publish-speaker-notes` and `--listen-speaker-notes` as they're a bit
shorter. Also I added a `speaker_notes.always_publish` configuration
parameter that causes the tool to always publish speaker notes unless
you're running in listen mode.
  • Loading branch information
mfontanini authored Jan 22, 2025
2 parents 954f112 + 98f1c38 commit 4bb9705
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 545 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@1.75.0
uses: dtolnay/rust-toolchain@1.78.0

- name: Run cargo check
run: cargo check --features sixel
Expand All @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v4

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@1.75.0
uses: dtolnay/rust-toolchain@1.78.0

- name: Run cargo test
run: cargo test
Expand Down
Loading

0 comments on commit 4bb9705

Please sign in to comment.