dolphin-components 2.2.15 → 2.2.16
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.
|
@@ -47162,15 +47162,15 @@ class cP {
|
|
|
47162
47162
|
this.url = e;
|
|
47163
47163
|
}
|
|
47164
47164
|
init() {
|
|
47165
|
-
return this.url == "" ? (console.log("❗WebSocket url not set!"), Promise.resolve(this)) :
|
|
47165
|
+
return this.url == "" ? (console.log("❗WebSocket url not set!"), Promise.resolve(this)) : this.socket && this.socket.readyState !== WebSocket.CLOSED && this.socket.readyState !== WebSocket.CLOSING ? (console.log("❗WebSocket is already initialized"), Promise.resolve(this)) : (this.socket = new WebSocket(this.url), new Promise((e, t) => {
|
|
47166
47166
|
this.socket.onopen = () => {
|
|
47167
47167
|
this.isConnected = !0, console.log("✅ WebSocket connected"), e(this);
|
|
47168
47168
|
}, this.socket.onclose = () => {
|
|
47169
|
-
this.isConnected = !1;
|
|
47169
|
+
this.isConnected = !1, console.log("❌ WebSocket connection closed");
|
|
47170
47170
|
}, this.socket.onerror = (i) => {
|
|
47171
47171
|
this.close(), console.error("⛔ WebSocket error occurred:", i), t(i);
|
|
47172
47172
|
};
|
|
47173
|
-
}))
|
|
47173
|
+
}));
|
|
47174
47174
|
}
|
|
47175
47175
|
onMessage(e) {
|
|
47176
47176
|
return this.socket ? (this.socket.onmessage = (t) => {
|
|
@@ -47192,7 +47192,7 @@ class cP {
|
|
|
47192
47192
|
});
|
|
47193
47193
|
}
|
|
47194
47194
|
close() {
|
|
47195
|
-
this.socket && (this.socket.close(), this.isConnected = !1, console.log("❌ WebSocket connection closed"));
|
|
47195
|
+
this.socket && (this.socket.close(), this.socket = null, this.isConnected = !1, console.log("❌ WebSocket connection closed"));
|
|
47196
47196
|
}
|
|
47197
47197
|
getConnectionStatus() {
|
|
47198
47198
|
return this.isConnected;
|