'createSubscribeQuery' only works when share is connected under WebSockets
- Dominant language
- JavaScript
- Stars
- 5k
- Forks
- 454
- PR merge metrics
- No merged PRs in 30d
Description
I'm pretty sure this is because "socket.canSendWhileConnecting" is not set- but _createQuery will silently fail in WebSockets like this:
``` js
var proto = 'ws'
var collection = 'files'
var socket = new WebSocket(proto + '://' + location.hostname + ':' + location.port)
var sharejs = require('share/lib/client/index')
var share = new sharejs.Connection(socket)
var query = share.createSubscribeQuery(collection, {}, {docMode:'sub'}, function(err, documents) {
console.log('not called')
})
```
while this will work as expected:
``` js
var proto = 'ws'
var collection = 'files'
var socket = new WebSocket(proto + '://' + location.hostname + ':' + location.port)
var sharejs = require('share/lib/client/index')
var share = new sharejs.Connection(socket)
share.on('connected', function() {
var query = share.createSubscribeQuery(collection, {}, {docMode:'sub'}, function(err, documents) {
console.log('called')
})
})
```
So, for WebSockets/BCSockets consistency the above should probably throw an error when canSendWhileConnecting is false.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.