You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
16
16
17
17
## [Unreleased]
18
18
19
+
### Added
20
+
21
+
- Direct Line Streaming: Added `networkInformation` option to assist detection of connection issues, by [@compulim](https://github.com/compulim), in PR [#412](https://github.com/microsoft/BotFramework-DirectLineJS/pull/412)
Client library for the [Microsoft Bot Framework](http://www.botframework.com)*[Direct Line](https://docs.botframework.com/en-us/restapi/directline3/)* protocol.
9
+
Client library for the [Microsoft Bot Framework](http://www.botframework.com)_[Direct Line](https://docs.botframework.com/en-us/restapi/directline3/)_ protocol.
10
10
11
11
Used by [WebChat](https://github.com/Microsoft/BotFramework-WebChat) and thus (by extension) [Emulator](https://github.com/Microsoft/BotFramework-Emulator), WebChat channel, and [Azure Bot Service](https://azure.microsoft.com/en-us/services/bot-service/).
12
12
13
13
## FAQ
14
14
15
-
### *Who is this for?*
15
+
### _Who is this for?_
16
16
17
17
Anyone who is building a Bot Framework JavaScript client who does not want to use [WebChat](https://github.com/Microsoft/BotFramework-WebChat).
18
18
19
19
If you're currently using WebChat, you don't need to make any changes as it includes this package.
20
20
21
-
### *What is that funny `subscribe()` method in the samples below?*
21
+
### _What is that funny `subscribe()` method in the samples below?_
22
22
23
23
Instead of callbacks or Promises, this library handles async operations using Observables. Try it, you'll like it! For more information, check out [RxJS](https://github.com/reactivex/rxjs/).
24
24
25
-
### *Can I use [TypeScript](http://www.typescriptlang.com)?*
25
+
### _Can I use [TypeScript](http://www.typescriptlang.com)?_
26
26
27
27
You bet.
28
28
@@ -32,6 +32,22 @@ This is an official Microsoft-supported library, and is considered largely compl
32
32
33
33
That said, the public API is still subject to change.
34
34
35
+
### Why the library did not detect Web Socket disconnections?
36
+
37
+
On iOS/iPadOS, when network change from Wi-Fi to cellular, the `WebSocket` object will be stalled without any errors. This is not detectable nor workaroundable without any additional assistance. The issue is related to an experimental feature named "NSURLSession WebSocket". The feature is enabled by default on iOS/iPadOS 15 and up.
38
+
39
+
An option named `networkInformation` can be used to assist the library to detect any connection issues. The option is based on [W3C Network Information API](https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API) and it should implement at least 2 members:
40
+
41
+
-[A `type` property](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/type) to indicate the current network type
42
+
- When the `type` is `"offline"`, network is not available and no connection will be made
43
+
-[A `change` event](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/change_event) should dispatch when the `type` property change
44
+
45
+
However, Safari on iOS/iPadOS [does not support W3C Network Information API](https://bugs.webkit.org/show_bug.cgi?id=185697). It is up to web developers to implement the `NetworkInformation` polyfill.
46
+
47
+
One effective way to detect network type change is to subscribe to a [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) source. The service would send a message every 30 seconds. If network type changed and current network type is no longer available, the connection will be closed prematurely and an `error` event will be dispatched to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) instance. Upon receiving the `error` event, the `NetworkInformation.type` should then change to `"offline"`. The browser would automatically retry the Server-Sent Events connection. Upon receiving an `open` event, the polyfill should change the `type` back to `"unknown"`.
48
+
49
+
If the library is being used in a native iOS/iPadOS app, a less resource-intensive solution would be partially implementing the [Network Information API](https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API) using [`NWPathMonitor`](https://developer.apple.com/documentation/network/nwpathmonitor). When network change happens, the `NetworkInformation` instance should update the [`type` property](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/type) based on network type and dispatch a [`change` event](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/change_event).
50
+
35
51
## How to build from source
36
52
37
53
0. Clone this repo
@@ -88,65 +104,58 @@ var directLine = new DirectLine({
Subscribing to either `postActivity` or `activity$` will start the process of connecting to the bot. Your app can listen to the connection status and react appropriately :
When using DirectLine with WebChat, closing the current tab or refreshing the page will create a new conversation in most cases. You can resume an existing conversation to keep the user in the same context.
169
178
170
179
**When using a secret** you can resume a conversation by:
171
-
- Storing the conversationid (in a *permanent* place, like local storage)
180
+
181
+
- Storing the conversationid (in a _permanent_ place, like local storage)
172
182
- Giving this value back while creating the DirectLine object along with the secret
173
183
174
184
```typescript
@@ -181,7 +191,8 @@ const dl = new DirectLine({
181
191
```
182
192
183
193
**When using a token** you can resume a conversation by:
184
-
- Storing the conversationid and your token (in a *permanent* place, like local storage)
194
+
195
+
- Storing the conversationid and your token (in a _permanent_ place, like local storage)
185
196
- Calling the DirectLine reconnect API yourself to get a refreshed token and a streamurl
186
197
- Creating the DirectLine object using the ConversationId, Token, and StreamUrl
187
198
@@ -196,7 +207,7 @@ const dl = new DirectLine({
196
207
```
197
208
198
209
**Getting any history that Direct Line has cached** : you can retrieve history using watermarks:
199
-
You can see the watermark as an *activity 'bookmark'*. The resuming scenario will replay all the conversation activities from the watermark you specify.
210
+
You can see the watermark as an _activity 'bookmark'_. The resuming scenario will replay all the conversation activities from the watermark you specify.
This project welcomes contributions and suggestions. Most contributions require you to agree to a
226
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
216
227
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
217
228
the rights to use your contribution. For details, visit https://cla.microsoft.com.
218
229
@@ -228,6 +239,7 @@ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.
228
239
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
229
240
230
241
## Reporting Security Issues
242
+
231
243
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
232
244
233
245
Copyright (c) Microsoft Corporation. All rights reserved.
0 commit comments