@subiz/wsclient 4.0.32 → 4.0.33

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "4.0.32",
3
+ "version": "4.0.33",
4
4
  "main": "realtime.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
package/realtime.js CHANGED
@@ -30,7 +30,7 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
30
30
  // The first loop begins after the first subscription call completes successfully
31
31
  var polling = function (backoff) {
32
32
  if (is_dead) return
33
- callAPI('get', apiUrl + 'poll?token=' + lastToken + '&account-id=' + accid, undefined, function (body, code) {
33
+ callAPI('get', apiUrl + 'poll?token=' + lastToken + '&v=5&account-id=' + accid, undefined, function (body, code) {
34
34
  if (is_dead) return
35
35
  if (retryable(code)) {
36
36
  is_polling_stuck = true
@@ -99,7 +99,8 @@ function Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {
99
99
  else if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)
100
100
  else if (access_token) query += '&access-token=' + access_token
101
101
 
102
- var fullurl = apiUrl + 'subs' + query + '&account-id=' + encodeURIComponent(accid || credential.account_id)
102
+ var fullurl =
103
+ apiUrl + 'subs' + query + '&v=5&account-id=' + encodeURIComponent(accid || credential.account_id)
103
104
  callAPI('post', fullurl, JSON.stringify({events: topics}), function (body, code) {
104
105
  if (done) return
105
106
  if (is_dead) {
@@ -234,17 +235,17 @@ function Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {
234
235
  // reconnect make sure there is alway a Conn running in the background
235
236
  // if the Conn is dead, it recreate a new one
236
237
  var conn
237
- let reconnect = function () {
238
+ var reconnect = function () {
238
239
  var randomUrl = apiUrls[Math.floor(Math.random() * apiUrls.length)]
239
240
  if (conn) conn.kill() // kill old connection
240
- let myconn = new Conn(
241
+ var myconn = new Conn(
241
242
  randomUrl,
242
243
  credential,
243
244
  function (code, body, status) {
244
245
  if (myconn != conn) return // outdated
245
246
  conn = undefined // prevent dupplicate dead fire
246
247
  pubsub.emit('interrupted', code, body, status)
247
- if (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec
248
+ // if (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec
248
249
  },
249
250
  function (events) {
250
251
  if (myconn != conn) return
package/realtime.test.js CHANGED
@@ -329,7 +329,7 @@ test.only('realtime', async (t) => {
329
329
 
330
330
  let ps = []
331
331
  for (const script of scripts) {
332
- if (script.name != 'resub') continue
332
+ // if (script.name != 'resub') continue
333
333
  ps.push(testScript(t, script))
334
334
  }
335
335
  await Promise.all(ps)