Skip to content
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

Updating RTCQuicTransport onstatechange event to Promise #83

Open
shampson opened this issue Nov 13, 2018 · 2 comments
Open

Updating RTCQuicTransport onstatechange event to Promise #83

shampson opened this issue Nov 13, 2018 · 2 comments
Labels

Comments

@shampson
Copy link
Collaborator

The state for the RTCQuicStream has been updated, but what about the RTCQuicTransport? The event currently fires for the following asynchronous cases:

  • transitioning from connecting --> connected
  • transitioning from connected --> failed
  • transitioning from connected --> closed

Why not use a Promise and remove the event because these are fire once events?
https://developers.google.com/web/fundamentals/primers/promises#events_arent_always_the_best_way

// Resolves when transport is closed due to a failure/errror or stop() being called on
// the remote side. Both of these mean a CONNECTION_CLOSE frame.
readonly attribute Promise<RTCQuicTransportStopInfo> transportClosed;
// Resolves when transport becomes connected.
readonly attribute Promise<void> transportConnected;

Without doing this or at least having an onstopped specific event for the Transport, the following PR isn't really useful:

  • PR 82 (Allows specifying errorCode with stop()).
  • Resolving issue 62

I would prefer not to add another onstopped specific event (now we again have two potential events that can fire for one event occurring). This would also fix issue 42, which fires two events for receiving an error (onstatechange connected-->failed & onerror).

@shampson
Copy link
Collaborator Author

Note - I'm going to think about this more and come back to it.

@shampson
Copy link
Collaborator Author

Update:
The CONNECTION_CLOSE frame has two types:

  • 0x1c for the QUIC layer, with transport error codes
  • 0x1d for the application layer, which manages its own protocol space for error codes

This promise based solution could be:

readonly attribute Promise<void> transportConnected;
readonly attribute Promise<RTCQuicRemoteTransportCloseInfo> remoteTransportClosed;

dictionary QuicTransportRemoteCloseInfo {
   // Application or QUIC level error code.
   unsigned short errorCode = 0;
   DOMString      reason = "";
   RemoteCloseType type;
};

enum RemoteCloseType {
  "application-stop",
  "quic-error"
}

I'll open a separate issue regarding the fix to include the StopInfo from stop() on the remote side and reference it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant