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:
@@ -5,7 +5,6 @@ const {TaskName, TaskPreconditions} = require('../utils/constants');
|
||||
const normalizeJambones = require('../utils/normalize-jambones');
|
||||
const makeTask = require('./make_task');
|
||||
const bent = require('bent');
|
||||
const uuidv4 = require('uuid/v4');
|
||||
const assert = require('assert');
|
||||
const WAIT = 'wait';
|
||||
const JOIN = 'join';
|
||||
@@ -239,7 +238,7 @@ class Conference extends Task {
|
||||
localServer: cs.srf.locals.localSipAddress,
|
||||
confServer: this.joinDetails.conferenceSipAddress
|
||||
}, `Conference:_doJoin: conference ${this.confName} is hosted elsewhere`);
|
||||
const success = await this._doRefer(cs, this.joinDetails.conferenceSipAddress);
|
||||
const success = await this.transferCallToFeatureServer(cs, this.joinDetails.conferenceSipAddress);
|
||||
|
||||
/**
|
||||
* If the REFER succeeded, we will get a BYE from the SBC
|
||||
@@ -277,7 +276,7 @@ class Conference extends Task {
|
||||
this.logger.info({members}, `Conference:doStart - notifying waiting list for ${this.confName}`);
|
||||
for (const url of members) {
|
||||
try {
|
||||
await bent('POST', 202)(url, {conferenceSipAddress: cs.srf.locals.localSipAddress});
|
||||
await bent('POST', 202)(url, {event: 'start', conferenceSipAddress: cs.srf.locals.localSipAddress});
|
||||
} catch (err) {
|
||||
this.logger.info(err, `Failed notifying ${url} to join ${this.confName}`);
|
||||
}
|
||||
@@ -363,37 +362,6 @@ class Conference extends Task {
|
||||
this.emitter.emit('join', opts);
|
||||
}
|
||||
|
||||
async _doRefer(cs, sipAddress) {
|
||||
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();
|
||||
|
||||
this.logger.debug({obj}, 'Conference:_doRefer');
|
||||
|
||||
const success = await addKey(uuid, JSON.stringify(obj), 30);
|
||||
if (!success) {
|
||||
this.logger.info(`Conference:_doRefer failed storing task data before REFER for ${this.confName}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.logger.info(`Conference:_doRefer: referring call to ${sipAddress} for ${this.confName}`);
|
||||
this.callMoved = true;
|
||||
const success = await cs.referCall(`sip:context-${uuid}@${sipAddress}`);
|
||||
if (!success) {
|
||||
this.callMoved = false;
|
||||
this.logger.info('Conference:_doRefer REFER failed');
|
||||
return success;
|
||||
}
|
||||
this.logger.info('Conference:_doRefer REFER succeeded');
|
||||
return success;
|
||||
} catch (err) {
|
||||
this.logger.error(err, 'Conference:_doRefer error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add ourselves to the waitlist of sessions to be notified once
|
||||
* the conference starts
|
||||
@@ -402,7 +370,7 @@ class Conference extends Task {
|
||||
async _addToWaitList(cs) {
|
||||
const {addToSet} = cs.srf.locals.dbHelpers;
|
||||
const setName = getWaitListName(this.confName);
|
||||
const url = `${cs.srf.locals.serviceUrl}/v1/startConference/${cs.callSid}`;
|
||||
const url = `${cs.srf.locals.serviceUrl}/v1/conference/${cs.callSid}`;
|
||||
const added = await addToSet(setName, url);
|
||||
if (added !== 1) throw new Error(`failed adding to the waitlist for conference ${this.confName}: ${added}`);
|
||||
this.logger.debug(`successfully added to the waiting list for conference ${this.confName}`);
|
||||
@@ -411,7 +379,7 @@ class Conference extends Task {
|
||||
async _removeFromWaitList(cs) {
|
||||
const {removeFromSet} = cs.srf.locals.dbHelpers;
|
||||
const setName = getWaitListName(this.confName);
|
||||
const url = `${cs.srf.locals.serviceUrl}/v1/startConference/${cs.callSid}`;
|
||||
const url = `${cs.srf.locals.serviceUrl}/v1/conference/${cs.callSid}`;
|
||||
try {
|
||||
const count = await removeFromSet(setName, url);
|
||||
this.logger.debug(`Conference:_removeFromWaitList removed ${count} from waiting list`);
|
||||
|
||||
Reference in New Issue
Block a user