add Time, reducing some duplication

This commit is contained in:
Zutatensuppe 2021-04-14 19:30:45 +02:00
parent e737015d7e
commit b6999e4f1f
7 changed files with 70 additions and 85 deletions

View file

@ -1,3 +1,5 @@
import Time from '../common/Time.js'
/**
* Wrapper around ws that
* - buffers 'send' until a connection is available
@ -48,12 +50,12 @@ export default class WsWrapper {
}
ws.onerror = (e) => {
this.handle = null
this.reconnectTimeout = setTimeout(() => { this.connect() }, 1000)
this.reconnectTimeout = setTimeout(() => { this.connect() }, 1 * Time.SEC)
this.onclose(e)
}
ws.onclose = (e) => {
this.handle = null
this.reconnectTimeout = setTimeout(() => { this.connect() }, 1000)
this.reconnectTimeout = setTimeout(() => { this.connect() }, 1 * Time.SEC)
this.onclose(e)
}
}