@swan-admin/swan-ai-measurements 1.0.39 → 1.0.40

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 (2) hide show
  1. package/measurement.js +28 -26
  2. package/package.json +1 -1
package/measurement.js CHANGED
@@ -104,31 +104,33 @@ export default class Measurement {
104
104
  if (!scanId) {
105
105
  throw new Error(REQUIRED_MESSAGE);
106
106
  }
107
- this.#disconnectSocket();
108
- const url = `${APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
109
- this.#measurementSocketRef = new WebSocket(url);
110
-
111
- this.#measurementSocketRef.onopen = () => {
112
- onOpen?.();
113
- this.#handleTimeOut(onSuccess, onError);
114
- };
115
-
116
- this.#measurementSocketRef.onmessage = (event) => {
117
- const data = JSON.parse(event.data);
118
- if (data?.code === 200 && data?.scanStatus === "success") {
119
- onSuccess?.(data);
120
- } else {
121
- onError?.(data);
122
- }
123
- clearTimeout(this.#timerWaitingRef);
124
- };
125
-
126
- this.#measurementSocketRef.onclose = () => {
127
- onClose?.();
128
- };
129
-
130
- this.#measurementSocketRef.onerror = (event) => {
131
- onError?.(event);
132
- };
107
+ setTimeout(() => {
108
+ this.#disconnectSocket();
109
+ const url = `${APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
110
+ this.#measurementSocketRef = new WebSocket(url);
111
+
112
+ this.#measurementSocketRef.onopen = () => {
113
+ onOpen?.();
114
+ this.#handleTimeOut(onSuccess, onError);
115
+ };
116
+
117
+ this.#measurementSocketRef.onmessage = (event) => {
118
+ const data = JSON.parse(event.data);
119
+ if (data?.code === 200 && data?.scanStatus === "success") {
120
+ onSuccess?.(data);
121
+ } else {
122
+ onError?.(data);
123
+ }
124
+ clearTimeout(this.#timerWaitingRef);
125
+ };
126
+
127
+ this.#measurementSocketRef.onclose = () => {
128
+ onClose?.();
129
+ };
130
+
131
+ this.#measurementSocketRef.onerror = (event) => {
132
+ onError?.(event);
133
+ };
134
+ }, 5000);
133
135
  };
134
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "index.js",
6
6
  "type": "module",