-
Notifications
You must be signed in to change notification settings - Fork 108
Docs for webrtc_socket/messages.rs #543
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
Open
Craig-Macomber
wants to merge
2
commits into
johanhelsing:main
Choose a base branch
from
Craig-Macomber:messages-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,43 @@ | ||
| //! Messages involved in the "signaling" process. | ||
| //! | ||
| //! These messages involve the signaling server and are used to establish the direct peer to peer | ||
| //! connections. | ||
| //! The direct peer to peer messages do not use these types: they use [`crate::Packet`]. | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Events go from signaling server to peer | ||
| /// Events which go from signaling server to peer. | ||
| pub type PeerEvent = matchbox_protocol::PeerEvent<PeerSignal>; | ||
|
|
||
| /// Requests go from peer to signaling server | ||
| /// Requests which go from peer to signaling server. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto, vice versa. |
||
| pub type PeerRequest = matchbox_protocol::PeerRequest<PeerSignal>; | ||
|
|
||
| /// Signals go from peer to peer via the signaling server | ||
| /// Signals which go from peer to peer via the signaling server. | ||
| /// | ||
| /// Wrapped by [`PeerRequest::Signal`] on the way to the signaling server, | ||
| /// and [`PeerEvent::Signal`] on the from the signalizing server the other peer. | ||
| #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] | ||
| pub enum PeerSignal { | ||
| /// Ice Candidate | ||
| /// [Ice (Interactive Connectivity Establishment) Candidate](https://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment). | ||
| // JSON encoding of an [`RTCIceCandidate`](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate). | ||
| // | ||
| // Note that while [`RTCIceCandidate`](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/RTCIceCandidate)'s | ||
| // constructor accepts a string for legacy purposes, that is not how this is being used: this | ||
| // is instead a | ||
| // [JSON encoding of the of the `RTCIceCandidate`](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidate/toJSON). | ||
| // | ||
| // When PeerSignal itself is JSON serialized, that results in JSON data as a string inside of | ||
| // another JSON string: this is inefficient (but negligibly so) and reduces type safety. | ||
| // It may be preferable refactor the abstraction implemented by the native and wasm sockets to | ||
| // have a with a more specific type instead of this to deduplicate their encoding logic | ||
| // and help ensure they are well aligned and can interoperate. | ||
| IceCandidate(String), | ||
| /// Offer | ||
| /// Offer a handshake. | ||
| /// | ||
| /// The contained string is the [`sdp`](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer#sdp). | ||
| Offer(String), | ||
| /// Answer | ||
| /// Answer accepting a handshake. | ||
| /// | ||
| /// The contained string is the [`sdp`](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/sdp). | ||
| Answer(String), | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the wording was intentional here to make it clear that events always go from server to peer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my phrasing, at least to me, this says that a "PeerEvent" is a kind of event which goes from server to peer, and I think thats accurate. There are lots of other kinds of events (For example RTCDataChannelEvent) and this sentence is clarifying that those other events are not PeerEvents.
I think the old phrasing seems like its trying to define the english word event with a really narrow definition, or clarify the server is able to pass events to the peer without stating that those events are PeerEvents.
I do think this would make sense:
Given that additional justification, would you prefer that, what I have in the PR, or the original phrasing?
I'm happy to update this and the one below to match based on your preference.