@mixd-id/web-scaffold 0.1.230406263 → 0.1.230406264

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406263",
4
+ "version": "0.1.230406264",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
package/src/utils/wss.js CHANGED
@@ -128,6 +128,7 @@ class WSS extends EventEmitter2{
128
128
  }
129
129
 
130
130
  socket.on('message', async (binaryData) => {
131
+ console.log('message#1', socket.isAuth)
131
132
  if(!socket.isAuth) return
132
133
 
133
134
  let obj
package/src/utils/wss.mjs CHANGED
@@ -119,8 +119,11 @@ class WSS extends EventEmitter2{
119
119
  const { _requestId, status, data, auth } = obj
120
120
 
121
121
  if(auth){
122
+ this._instance.isAuth = auth
123
+
122
124
  reconnect ? this.emit('reconnect', null, []) : this.emit('connect', null, [])
123
125
 
126
+ console.log('pending send', this._pendingSend)
124
127
  for(let sendParams of this._pendingSend){
125
128
  this.sendSync(sendParams.path, sendParams.params, sendParams.cb, sendParams.err)
126
129
  }
@@ -181,13 +184,15 @@ class WSS extends EventEmitter2{
181
184
  }
182
185
 
183
186
  sendSync(path, params, cb, err, override){
187
+ console.log('sendSync', path, this._instance.readyState)
184
188
 
185
- if(this._instance.readyState === 0){
186
- this._pendingSend.push({ path, params, cb, err })
189
+ if(this._instance.readyState > 1){
190
+ console.log('unable to send, ready state not 1', this._instance.readyState)
187
191
  return
188
192
  }
189
- else if(this._instance.readyState !== 1){
190
- console.log('unable to send, ready state not 1', this._instance.readyState)
193
+ else if(!this._instance.isAuth){
194
+ console.log('add pending send', { path, params, cb, err })
195
+ this._pendingSend.push({ path, params, cb, err })
191
196
  return
192
197
  }
193
198
 
@@ -234,6 +239,12 @@ class WSS extends EventEmitter2{
234
239
  })
235
240
  }
236
241
 
242
+ async resume(){
243
+ if(this._instance.readyState > 1){
244
+ return this.reconnect()
245
+ }
246
+ }
247
+
237
248
  }
238
249
 
239
250
  export {