support OPTIONS ping to SBCs

This commit is contained in:
Dave Horton
2020-02-17 21:41:35 -05:00
parent 3c89b7fd76
commit 162dfff5a3
9 changed files with 109 additions and 77 deletions

View File

@@ -5,7 +5,7 @@ const assert = require('assert');
const sessionTracker = require('./session-tracker');
const makeTask = require('../tasks/make_task');
const normalizeJamones = require('../utils/normalize-jamones');
const list = require('../utils/summarize-tasks');
const listTaskNames = require('../utils/summarize-tasks');
const BADPRECONDITIONS = 'preconditions not met';
/**
@@ -140,7 +140,7 @@ class CallSession extends Emitter {
* @async
*/
async exec() {
this.logger.info({tasks: list(this.tasks)}, `CallSession:exec starting ${this.tasks.length} tasks`);
this.logger.info({tasks: listTaskNames(this.tasks)}, `CallSession:exec starting ${this.tasks.length} tasks`);
while (this.tasks.length && !this.callGone) {
const taskNum = ++this.taskIdx;
const stackNum = this.stackIdx;
@@ -228,7 +228,7 @@ class CallSession extends Emitter {
async _lccCallHook(opts) {
const tasks = await this.requestor.request(opts.call_hook, this.callInfo);
if (tasks && tasks.length > 0) {
this.logger.info({tasks}, 'CallSession:updateCall new task list');
this.logger.info({tasks: listTaskNames(tasks)}, 'CallSession:updateCall new task list');
this.replaceApplication(normalizeJamones(this.logger, tasks).map((tdata) => makeTask(this.logger, tdata)));
}
}
@@ -363,7 +363,7 @@ class CallSession extends Emitter {
this.tasks = tasks;
this.taskIdx = 0;
this.stackIdx++;
this.logger.info({tasks},
this.logger.info({tasks: listTaskNames(tasks)},
`CallSession:replaceApplication reset with ${tasks.length} new tasks, stack depth is ${this.stackIdx}`);
if (this.currentTask) {
this.currentTask.kill();
@@ -484,8 +484,10 @@ class CallSession extends Emitter {
*/
async getMS() {
if (!this.ms) {
const fsOpts = this.srf.locals.getFreeswitch();
if (!fsOpts) throw new Error('no available freeswitch');
const mrf = this.srf.locals.mrf;
this.ms = await mrf.connect(this.srf.locals.freeswitch);
this.ms = await mrf.connect(fsOpts);
}
return this.ms;
}
@@ -500,7 +502,9 @@ class CallSession extends Emitter {
// get a media server
if (!this.ms) {
this.ms = await mrf.connect(this.srf.locals.freeswitch);
const fsOpts = this.srf.locals.getFreeswitch();
if (!fsOpts) throw new Error('no available freeswitch');
this.ms = await mrf.connect(fsOpts);
}
if (!this.ep) {
this.ep = await this.ms.createEndpoint({remoteSdp: this.req.body});

View File

@@ -21,6 +21,10 @@ class SessionTracker extends Emitter {
return this._logger;
}
get count() {
return this.sessions.size;
}
/**
* Adds a new CallSession to the Map
* @param {string} callSid