mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
initial support for conference and queues
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const Emitter = require('events');
|
||||
const uuidv4 = require('uuid/v4');
|
||||
const debug = require('debug')('jambonz:feature-server');
|
||||
const assert = require('assert');
|
||||
const {TaskPreconditions} = require('../utils/constants');
|
||||
@@ -98,6 +99,38 @@ class Task extends Emitter {
|
||||
}
|
||||
}
|
||||
|
||||
async transferCallToFeatureServer(cs, sipAddress, opts) {
|
||||
const uuid = uuidv4();
|
||||
const {addKey} = cs.srf.locals.dbHelpers;
|
||||
const obj = Object.assign({}, cs.application);
|
||||
delete obj.requestor;
|
||||
delete obj.notifier;
|
||||
obj.tasks = cs.getRemainingTaskData();
|
||||
if (opts && obj.tasks.length > 1) obj.tasks[0]._ = opts;
|
||||
|
||||
this.logger.debug({obj}, 'Task:_doRefer');
|
||||
|
||||
const success = await addKey(uuid, JSON.stringify(obj), 30);
|
||||
if (!success) {
|
||||
this.logger.info(`Task:_doRefer failed storing task data before REFER for ${this.queueName}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.logger.info(`Task:_doRefer: referring call to ${sipAddress} for ${this.queueName}`);
|
||||
this.callMoved = true;
|
||||
const success = await cs.referCall(`sip:context-${uuid}@${sipAddress}`);
|
||||
if (!success) {
|
||||
this.callMoved = false;
|
||||
this.logger.info('Task:_doRefer REFER failed');
|
||||
return success;
|
||||
}
|
||||
this.logger.info('Task:_doRefer REFER succeeded');
|
||||
return success;
|
||||
} catch (err) {
|
||||
this.logger.error(err, 'Task:_doRefer error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate that the JSON task description is valid
|
||||
* @param {string} name - verb name
|
||||
|
||||
Reference in New Issue
Block a user