fix timeout typescript.
This commit is contained in:
parent
45ef058bf4
commit
38bed98741
@ -190,7 +190,7 @@
|
||||
if (this.shakeKbd || this.$accessor.remote.hosted) return
|
||||
|
||||
this.shakeKbd = true
|
||||
setTimeout(() => (this.shakeKbd = false), 5000)
|
||||
window.setTimeout(() => (this.shakeKbd = false), 5000)
|
||||
}
|
||||
|
||||
get about() {
|
||||
|
@ -45,7 +45,7 @@
|
||||
@Ref('textarea') readonly _textarea!: HTMLTextAreaElement
|
||||
|
||||
private opened: boolean = false
|
||||
private typing: any = null
|
||||
private typing?: number
|
||||
|
||||
get clipboard() {
|
||||
return this.$accessor.remote.clipboard
|
||||
@ -56,15 +56,16 @@
|
||||
|
||||
if (this.typing) {
|
||||
clearTimeout(this.typing)
|
||||
this.typing = undefined
|
||||
}
|
||||
|
||||
this.typing = setTimeout(() => this.$accessor.remote.sendClipboard(this.clipboard), 500)
|
||||
this.typing = window.setTimeout(() => this.$accessor.remote.sendClipboard(this.clipboard), 500)
|
||||
}
|
||||
|
||||
open() {
|
||||
this.opened = true
|
||||
document.body.addEventListener('click', this.close)
|
||||
setTimeout(() => this._textarea.focus(), 0)
|
||||
window.setTimeout(() => this._textarea.focus(), 0)
|
||||
}
|
||||
|
||||
close() {
|
||||
|
@ -15,7 +15,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
protected _ws?: WebSocket
|
||||
protected _peer?: RTCPeerConnection
|
||||
protected _channel?: RTCDataChannel
|
||||
protected _timeout?: NodeJS.Timeout
|
||||
protected _timeout?: number
|
||||
protected _displayname?: string
|
||||
protected _state: RTCIceConnectionState = 'disconnected'
|
||||
protected _id = ''
|
||||
@ -65,7 +65,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
this._ws.onmessage = this.onMessage.bind(this)
|
||||
this._ws.onerror = (event) => this.onError.bind(this)
|
||||
this._ws.onclose = (event) => this.onDisconnected.bind(this, new Error('websocket closed'))
|
||||
this._timeout = setTimeout(this.onTimeout.bind(this), 15000)
|
||||
this._timeout = window.setTimeout(this.onTimeout.bind(this), 15000)
|
||||
} catch (err) {
|
||||
this.onDisconnected(err)
|
||||
}
|
||||
@ -74,6 +74,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
protected disconnect() {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout)
|
||||
this._timeout = undefined
|
||||
}
|
||||
|
||||
if (this._ws) {
|
||||
@ -223,6 +224,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
case 'checking':
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout)
|
||||
this._timeout = undefined
|
||||
}
|
||||
break
|
||||
case 'connected':
|
||||
@ -325,6 +327,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
private onConnected() {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout)
|
||||
this._timeout = undefined
|
||||
}
|
||||
|
||||
if (!this.connected) {
|
||||
@ -340,6 +343,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
this.emit('debug', `connection timeout`)
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout)
|
||||
this._timeout = undefined
|
||||
}
|
||||
this.onDisconnected(new Error('connection timeout'))
|
||||
}
|
||||
|
Reference in New Issue
Block a user