@meta2d/core 1.0.91 → 1.0.93

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/src/core.js CHANGED
@@ -2527,7 +2527,7 @@ export class Meta2d {
2527
2527
  // Object.assign(options,{clean: false});
2528
2528
  // }
2529
2529
  if (!options.hasOwnProperty("reconnectPeriod")) {
2530
- Object.assign(options, { reconnectPeriod: 0 });
2530
+ Object.assign(options, { reconnectPeriod: 5000 });
2531
2531
  }
2532
2532
  if (!options.hasOwnProperty("connectTimeout")) {
2533
2533
  Object.assign(options, { connectTimeout: 10 * 1000 });
@@ -2545,24 +2545,25 @@ export class Meta2d {
2545
2545
  this.mqttClients[net.index].on('error', (error) => {
2546
2546
  this.store.emitter.emit('error', { type: 'mqtt', error });
2547
2547
  });
2548
- let reconnectDelay = 1000;
2549
- this.mqttClients[net.index].on('close', () => {
2550
- if (this.store.options.reconnetTimes) {
2551
- net.times++;
2552
- if (net.times >= this.store.options.reconnetTimes) {
2553
- net.times = 0;
2554
- this.mqttClients && this.mqttClients[net.index]?.end();
2555
- }
2556
- setTimeout(() => {
2557
- if (net.times < this.store.options.reconnetTimes) {
2558
- this.mqttClients[net.index].reconnect(options);
2559
- reconnectDelay = Math.min(reconnectDelay * 2, 10 * 1000);
2560
- }
2561
- }, reconnectDelay);
2562
- }
2563
- });
2548
+ //mqtt 默认重连配置 reconnectPeriod
2549
+ // let reconnectDelay = 1000;
2550
+ // this.mqttClients[net.index].on('close', () => {
2551
+ // if (this.store.options.reconnetTimes) {
2552
+ // net.times++;
2553
+ // if (net.times >= this.store.options.reconnetTimes) {
2554
+ // net.times = 0;
2555
+ // this.mqttClients && this.mqttClients[net.index]?.end();
2556
+ // }
2557
+ // setTimeout(()=>{
2558
+ // if (net.times < this.store.options.reconnetTimes) {
2559
+ // this.mqttClients[net.index].reconnect(options as any);
2560
+ // reconnectDelay = Math.min(reconnectDelay * 2, 10 * 1000);
2561
+ // }
2562
+ // },reconnectDelay)
2563
+ // }
2564
+ // });
2564
2565
  this.mqttClients[net.index].on('connect', (connack) => {
2565
- reconnectDelay = 1000;
2566
+ // reconnectDelay = 1000;
2566
2567
  if (!connack.sessionPresent) {
2567
2568
  // 创建了新会话或没有找到旧会话,需要重新订阅主题
2568
2569
  if (net.topics) {
@@ -2633,7 +2634,7 @@ export class Meta2d {
2633
2634
  const res = await fetch('/api/iot/app/mqtt', {
2634
2635
  method: 'GET',
2635
2636
  headers: {
2636
- Authorization: `Bearer ${getToken()}`,
2637
+ Authorization: getToken(),
2637
2638
  },
2638
2639
  });
2639
2640
  if (res.ok) {
@@ -2650,7 +2651,7 @@ export class Meta2d {
2650
2651
  const res = await fetch('/api/iot/subscribe/properties', {
2651
2652
  method: 'POST',
2652
2653
  headers: {
2653
- Authorization: `Bearer ${getToken()}`,
2654
+ Authorization: getToken(),
2654
2655
  },
2655
2656
  body: JSON.stringify({ devices: devices, type }),
2656
2657
  });
@@ -2663,7 +2664,7 @@ export class Meta2d {
2663
2664
  const ret = await fetch(`/api/iot/unsubscribe/properties`, {
2664
2665
  method: 'POST',
2665
2666
  headers: {
2666
- Authorization: `Bearer ${getToken()}`,
2667
+ Authorization: getToken(),
2667
2668
  },
2668
2669
  body: JSON.stringify({ token }),
2669
2670
  });
@@ -2688,7 +2689,7 @@ export class Meta2d {
2688
2689
  const res = await fetch(`/api/iot/data/sql/${method}`, {
2689
2690
  method: 'POST',
2690
2691
  headers: {
2691
- Authorization: `Bearer ${getCookie('token') || localStorage.getItem('token') || new URLSearchParams(location.search).get('token') || ''}`,
2692
+ Authorization: getToken(),
2692
2693
  },
2693
2694
  body: JSON.stringify({ dbId: sql.dbId || sql.dbid, sql: _sql, }),
2694
2695
  });