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

Add networkInformation object to DLASE #412

Merged
merged 33 commits into from
Jul 11, 2023

Conversation

compulim
Copy link
Collaborator

@compulim compulim commented Jul 11, 2023

Changelog

Added

  • Direct Line Streaming: Added networkInformation option to assist detection of connection issues, by @compulim, in PR #412

Designs

On iOS/iPadOS Safari, when connection change from Wi-Fi to cellular (say, walking away from coffee shop), the WebSocket object did not emit error event. It simply stalled. This only repros on iOS/iPadOS. It did not repro on Android Chrome.

To detect network type change, we could use networkInformation.type. However, Network Information API is not implemented in Safari.

We are adding a new option to allow web developers to provide a polyfill of W3C Network Information API. They could implement the polyfill using Server-Sent Events or native calls to NWPathMonitor.

When the NetworkInformation instance detected network change, it should:

  1. Change type to current network type, such as "cellular", "wifi", "unknown", or "none" (offline)
  2. Emit change event

Upon receiving the change event with type property changed, the chat adapter would terminate the current Web Socket connection and retries.

Currently, despite Network Information API is implemented in modern browsers, the type property may not be implemented. A simple polyfill for the type property:

Object.defineProperty(navigator.connection, 'type', {
  get() {
    return this.downlink ? 'unknown' : 'none';
  }
});

Specific changes

  • Added networkInformation to DirectLineStreaming options

@compulim compulim requested a review from a team as a code owner July 11, 2023 20:02
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
compulim and others added 2 commits July 11, 2023 13:39
Co-authored-by: TJ Durnford <tjdford@gmail.com>
ckkashyap
ckkashyap previously approved these changes Jul 11, 2023
src/directLineStreaming.ts Show resolved Hide resolved
@compulim compulim merged commit d07e655 into microsoft:master Jul 11, 2023
2 checks passed
@compulim compulim deleted the feat-add-watchdog-ase branch July 11, 2023 23:41
This pull request was closed.
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