mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
add support for ws verb:status event notifications (#196)
This commit is contained in:
@@ -4,6 +4,7 @@ const debug = require('debug')('jambonz:feature-server');
|
||||
const assert = require('assert');
|
||||
const {TaskPreconditions} = require('../utils/constants');
|
||||
const normalizeJambones = require('../utils/normalize-jambones');
|
||||
const WsRequestor = require('../utils/ws-requestor');
|
||||
const {trace} = require('@opentelemetry/api');
|
||||
const specs = new Map();
|
||||
const _specData = require('./specs');
|
||||
@@ -21,6 +22,7 @@ class Task extends Emitter {
|
||||
this.logger = logger;
|
||||
this.data = data;
|
||||
this.actionHook = this.data.actionHook;
|
||||
this.id = data.id;
|
||||
|
||||
this._killInProgress = false;
|
||||
this._completionPromise = new Promise((resolve) => this._completionResolver = resolve);
|
||||
@@ -137,10 +139,20 @@ class Task extends Emitter {
|
||||
return this.callSession.normalizeUrl(url, method, auth);
|
||||
}
|
||||
|
||||
notifyError(errMsg) {
|
||||
const params = {error: errMsg, verb: this.name};
|
||||
this.cs.requestor.request('jambonz:error', '/error', params)
|
||||
.catch((err) => this.logger.info({err}, 'Task:notifyError error sending error'));
|
||||
notifyError(obj) {
|
||||
if (this.cs.requestor instanceof WsRequestor) {
|
||||
const params = {...obj, verb: this.name, id: this.id};
|
||||
this.cs.requestor.request('jambonz:error', '/error', params)
|
||||
.catch((err) => this.logger.info({err}, 'Task:notifyError error sending error'));
|
||||
}
|
||||
}
|
||||
|
||||
notifyStatus(obj) {
|
||||
if (this.cs.notifyEvents && this.cs.requestor instanceof WsRequestor) {
|
||||
const params = {...obj, verb: this.name, id: this.id};
|
||||
this.cs.requestor.request('verb:status', '/status', params)
|
||||
.catch((err) => this.logger.info({err}, 'Task:notifyStatus error sending error'));
|
||||
}
|
||||
}
|
||||
|
||||
async performAction(results, expectResponse = true) {
|
||||
|
||||
Reference in New Issue
Block a user