add headers manipulation.

This commit is contained in:
Miroslav Šedivý 2020-12-24 03:23:08 +01:00
parent c9290bd88a
commit c7fde94ac4

View File

@ -308,6 +308,17 @@
this.cookieHander = func this.cookieHander = func
} }
// TODO: Refactor.
public headerEvent(event: string, payload?: any | undefined) {
this.websocket.send('headers/' + event, { payload })
}
// TODO: Refactor.
headerHander?: (event: string, payload: any) => any
public headerSubscribe(func: (event: string, payload: any) => any) {
this.headerHander = func
}
///////////////////////////// /////////////////////////////
// Component lifecycle // Component lifecycle
///////////////////////////// /////////////////////////////
@ -344,6 +355,11 @@
if (event.match(/^cookies\//) && this.cookieHander) { if (event.match(/^cookies\//) && this.cookieHander) {
this.cookieHander(event, payload.payload) this.cookieHander(event, payload.payload)
} }
// TODO: Refactor.
if (event.match(/^headers\//) && this.headerHander) {
this.headerHander(event, payload.payload)
}
}) })
this.websocket.on('connecting', () => { this.websocket.on('connecting', () => {
Vue.set(this.state.connection, 'websocket', 'connecting') Vue.set(this.state.connection, 'websocket', 'connecting')