WebBluetoothCG / web-bluetooth

Bluetooth support for the Web.
http://www.w3.org/community/web-bluetooth/
Other
1.39k stars 188 forks source link

Allow device connections from only one script context at a time. #169

Closed scheib closed 8 years ago

scheib commented 9 years ago

Connection, notification, read & writes, are all problematic if multiple script contexts can be issuing commands to one device. I propose that the specification only permit connection to a device from one context.

beaufortfrancois commented 9 years ago

Let's say I open a browser tab and starts to interact with a nearby BT device. Then, I open a second tab (same URL) and perform "requestDevice". How will user know that selecting the previous device will actually interrupt the first tab there?

scheib commented 9 years ago

We have a few options:

beaufortfrancois commented 9 years ago

I'd personally vote for option 3 but I'd love to hear what other think. I may add a specific JS error so that developer could explain what went wrong to user so that he can understand.

jyasskin commented 9 years ago

I'm really reluctant to add this restriction on developers and users. We should prefer making our implementation somewhat more complex so that websites and user experiences can be less complex.

If we do it, I think "just disconnect the other page" is the only plausible way: we shouldn't show UI on an event the user might not be expecting, and we can't give the web page enough information for it to tell the user which other page to close.

jracle commented 8 years ago

If I could add a fourth option here : don't disconnect device (aka NOP™)..

Also please consider the fact that other apps will be notified of device disconnection.

At Logitech, our devices use to communicate with multiple apps at the same time, leaving underlying app / protocol responsibility to sort its own requests / responses from the whole.

If firmware and GATT driver supports it, why should we have to limit number of connections to our peripheral?

Furthermore, OS also maintains connections in case your device has Hid over GATT profile. So you might end-up closing connection to those mice / keyboards.

I'll also open another issue concerning behavior of GATT server disconnect.