Skip to content

feat: ephemeral peer channels #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 31, 2024
Merged

feat: ephemeral peer channels #6

merged 11 commits into from
May 31, 2024

Conversation

Septias
Copy link
Contributor

@Septias Septias commented Apr 9, 2024

Part of 5346

webxdc.d.ts Outdated

/**
* Set a listener for _ephemeral_ status updates.
* Own status updates are not received.
Copy link

Choose a reason for hiding this comment

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

Does this trigger a regular message to announce the peer-address?
Does this wait on anything?
IOW: the docs are not clarifying what a caller can expect in terms of how connectivity happens (same question for setEphemeralUpdateListener.

Copy link
Contributor Author

@Septias Septias Apr 9, 2024

Choose a reason for hiding this comment

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

Desktop explicitly calls send_gossip_advertisement to send out an advertisement with the current IP address. The async call resolves when at least one peer is connected and the swarm is operatable.

webxdc.js Outdated
// browsers. In an actual webxdc environment (e.g. Delta Chat messenger) this
// file is not used and will automatically be replaced with a real one.
// See https://docs.webxdc.org/spec.html#webxdc-api
Copy link

Choose a reason for hiding this comment

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

this addition does not relate to the PR topic. Why not as a PR to the hello-repo which would diverge as soon as we merge this PR here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello repo also has a PR. For people who only look at this repo it might be interesting to have a mock implementation as well. The true source is linked so a divergence is acceptable imo.

webxdc.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

this file is wrong, this repo is only about types. if you add it here bundlers will do mess with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a usability perspective, I find it way better to have a working implementation of webxdc.js . It's always easier to just delete code instead of trying to find a good implementation. Maybe it's also enough to just add a reference to the hello repository implementation.

Copy link
Contributor

@Simon-Laux Simon-Laux Apr 13, 2024

Choose a reason for hiding this comment

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

make an extra package for that, including it here will not have the effect you want. this package is types only

Copy link
Contributor

@Simon-Laux Simon-Laux Apr 13, 2024

Choose a reason for hiding this comment

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

having an extra package for the emulator would also make syncing & updating it easier, see webxdc/vite-plugins#2 which also includes the emulator.
currently the emulator lives in the hello repo, the hello repo is a minimal example how to develop apps without npm packages, so it is kinda outside of the rest.

Still this package is only for types and the webxdc.js is only a dummy for the bundlers to make them compile (and not complain about a missing file), as it clearly(?) states in its comment. If you put an emulator there it will be bundled and thus never replaced by the host (deltachat or cheogram), because the bundler inlines it and changes its name. so you would have a non working app, not what you want.

@Simon-Laux
Copy link
Contributor

I fixed most issue I raised here in #8, please review that and merge it into this pr.

Fixes for the ephemeral_peer_channels pr (#6)
webxdc.d.ts Outdated
@@ -101,7 +101,7 @@ interface Webxdc<StatusPayload, EphemeralPayload = any> {
* Send an ephemeral update to another peer.
* @param payload Data that can be serialized with `JSON.stringify`.
*
* @returns resolves when (TODO is it when it is sent or registered by core?)
* @returns A promise that resolves when a peer connection is established. Ephemeral messages can then be sent with `sendEphemeral`
Copy link
Contributor

Choose a reason for hiding this comment

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

are you paying attention? this is sendEphemeralUpdate, your edit seems like it was meant for setEphemeralUpdateListener

webxdc.d.ts Outdated
Comment on lines 68 to 69
active: boolean
trashed: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

is one of these private? or "readonly"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already marked locally

Copy link
Contributor

Choose a reason for hiding this comment

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

just tried it out in the ts playground, seems like typescript needs an explicit private or protected keyword, it is not like rust where everything is private by default. maybe there is a compiler flag for this, but I wouldn't bet on that.

@Septias Septias requested review from Simon-Laux, hpk42 and WofWca May 12, 2024 14:07
Copy link

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

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

as far as i can tell, this looks good.

@hpk42
Copy link

hpk42 commented May 12, 2024 via email

@Septias
Copy link
Contributor Author

Septias commented May 12, 2024

Yeah, but that error will be much less helpfull

Co-authored-by: WofWca <[email protected]>
@Septias Septias merged commit 115a055 into main May 31, 2024
@Simon-Laux Simon-Laux deleted the sk/ephemeral_peer_channels branch May 31, 2024 18:15
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.

4 participants