Небольшие поправки

This commit is contained in:
Book Pauk
2020-01-22 20:28:46 +07:00
parent 4cccb56ee3
commit e36dc4a913
2 changed files with 4 additions and 2 deletions

View File

@@ -52,12 +52,13 @@ class WebSocketConnection {
return this.listeners.length != len;
}
open() {
open(url) {
return new Promise((resolve, reject) => {
if (this.ws && this.ws.readyState == WebSocket.OPEN) {
resolve(this.ws);
} else {
this.ws = new WebSocket(`ws://${window.location.host}`);
url = url || `ws://${window.location.host}/ws`;
this.ws = new WebSocket(url);
if (this.timer) {
clearTimeout(this.timer);

View File

@@ -36,6 +36,7 @@ class Reader {
return response;
} catch (e) {
//
console.error(e);
}
//с WebSocket проблема, проверяем по http