larasopp 1.2.2 → 1.2.4

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/lib/Core.js CHANGED
@@ -61,10 +61,6 @@ class Core {
61
61
  * @returns {this}
62
62
  */
63
63
  connect() {
64
- if (!navigator.onLine) {
65
- setTimeout(this.connect.bind(this), 5000);
66
- return this;
67
- }
68
64
  try {
69
65
  const host = [(this.config.tls ? 'wss' : 'ws') + '://'];
70
66
  host.push(this.config.host);
@@ -137,8 +133,6 @@ class Core {
137
133
  return this._socketId;
138
134
  }
139
135
  get status() {
140
- if (!this._status)
141
- this.connect();
142
136
  return this._status;
143
137
  }
144
138
  _send(message) {
@@ -147,10 +141,13 @@ class Core {
147
141
  this.ws.send(JSON.stringify(message));
148
142
  }
149
143
  send(message) {
144
+ var _a;
150
145
  if (this.status) {
151
146
  this._send(message);
152
147
  }
153
148
  else {
149
+ if (!((_a = this.ws) === null || _a === void 0 ? void 0 : _a.CONNECTING))
150
+ this.connect();
154
151
  const event = this.events.addListener('open', () => {
155
152
  this._send(message);
156
153
  event.remove();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larasopp",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Websocket client for laravel",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/Core.ts CHANGED
@@ -52,7 +52,7 @@ abstract class Core {
52
52
  ...config,
53
53
  };
54
54
  this._status = false;
55
-
55
+
56
56
  this.handleOpen = this.handleOpen.bind(this);
57
57
  this.handleClose = this.handleClose.bind(this);
58
58
  this.handleError = this.handleError.bind(this);
@@ -160,7 +160,6 @@ abstract class Core {
160
160
  }
161
161
 
162
162
  public get status(): boolean {
163
- if (!this._status) this.connect();
164
163
  return this._status;
165
164
  }
166
165
 
@@ -173,6 +172,7 @@ abstract class Core {
173
172
  if (this.status) {
174
173
  this._send(message);
175
174
  }else{
175
+ if (!this.ws?.CONNECTING) this.connect();
176
176
  const event = this.events.addListener('open',() => {
177
177
  this._send(message);
178
178
  event.remove();