added AbortController support

This commit is contained in:
srgooglo 2022-09-09 14:52:50 +02:00
parent b8926dfdab
commit 1bf59c18c9

View File

@ -13,6 +13,7 @@ module.exports = class Bridge {
constructor(params = {}, events = {}) { constructor(params = {}, events = {}) {
this.params = params this.params = params
this.events = events this.events = events
this.internalAbortController = new AbortController()
this.origin = this.params.origin this.origin = this.params.origin
this.wsOrigin = this.origin.replace(/^http/, "ws") this.wsOrigin = this.origin.replace(/^http/, "ws")
@ -24,8 +25,10 @@ module.exports = class Bridge {
this.httpInterface = axios.create({ this.httpInterface = axios.create({
baseURL: this.origin, baseURL: this.origin,
headers: this.headers headers: this.headers,
signal: this.params.signal ?? this.internalAbortController.signal
}) })
this.wsInterface = new WSInterface({ this.wsInterface = new WSInterface({
origin: this.wsOrigin, origin: this.wsOrigin,
managerOptions: this.params.wsOptions, managerOptions: this.params.wsOptions,