statebus 6.1.18 → 6.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/client.js +6 -5
  2. package/package.json +1 -1
  3. package/server.js +5 -4
package/client.js CHANGED
@@ -1,5 +1,6 @@
1
1
  (function () {
2
- var unique_sockjs_string = '_connect_to_statebus_'
2
+ var websocket_prefix = (clientjs_option('websocket_path')
3
+ || '_connect_to_statebus_')
3
4
 
4
5
  window.dom = window.dom || new Proxy({}, {
5
6
  get: function (o, k) { return o[k] },
@@ -37,8 +38,8 @@
37
38
  // url = link.href
38
39
  // }
39
40
  console.log('opening websocket to', url)
40
- return new WebSocket(url + '/' + unique_sockjs_string + '/websocket')
41
- // return new SockJS(url + '/' + unique_sockjs_string)
41
+ return new WebSocket(url + '/' + websocket_prefix + '/websocket')
42
+ // return new SockJS(url + '/' + websocket_prefix)
42
43
  }
43
44
  function client_creds (server_url) {
44
45
  var me = bus.fetch('ls/me')
@@ -97,9 +98,9 @@
97
98
  subscribe: true,
98
99
  headers: {accept: 'application/json'}
99
100
  }
100
- ).andThen( x => {
101
+ ).andThen( function (x) {
101
102
  t.return({
102
- key,
103
+ key: key,
103
104
  val: add_prefixes(JSON.parse(x.body))
104
105
  })
105
106
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statebus",
3
- "version": "6.1.18",
3
+ "version": "6.1.20",
4
4
  "description": "Synchronize state.",
5
5
  "main": "statebus.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -1,6 +1,5 @@
1
1
  var fs = require('fs'),
2
2
  util = require('util')
3
- var unique_sockjs_string = '_connect_to_statebus_'
4
3
 
5
4
  // Import braidify if it's available
6
5
  try {
@@ -22,6 +21,7 @@ function default_options (bus) { return {
22
21
  certificate: 'certs/certificate',
23
22
  certificate_bundle: 'certs/certificate-bundle'},
24
23
  connections: {include_users: true, edit_others: true},
24
+ websocket_path: '_connect_to_statebus_',
25
25
  __secure: false
26
26
  }}
27
27
 
@@ -386,7 +386,8 @@ function import_server (bus, options)
386
386
  this.http_server.on('request', // Install express
387
387
  function (request, response) {
388
388
  // But express should ignore all sockjs requests
389
- if (!request.url.startsWith('/'+unique_sockjs_string+'/'))
389
+ if (!request.url.startsWith(
390
+ '/' + bus.options.websocket_path + '/'))
390
391
  express_app(request, response)
391
392
  })
392
393
 
@@ -586,7 +587,7 @@ function import_server (bus, options)
586
587
  }
587
588
  })
588
589
 
589
- s.installHandlers(httpserver, {prefix:'/' + unique_sockjs_string})
590
+ s.installHandlers(httpserver, {prefix:'/' + bus.options.websocket_path})
590
591
  },
591
592
 
592
593
  make_websocket: function make_websocket (url) {
@@ -594,7 +595,7 @@ function import_server (bus, options)
594
595
  url = url.replace(/^istate:\/\//, 'ws://')
595
596
  url = url.replace(/^statei:\/\//, 'ws://')
596
597
  WebSocket = require('websocket').w3cwebsocket
597
- return new WebSocket(url+'/'+unique_sockjs_string+'/websocket')
598
+ return new WebSocket(url+'/'+bus.options.websocket_path+'/websocket')
598
599
  },
599
600
  client_creds: function client_creds (server_url) {
600
601
  // Right now the server just creates a different random id each time