mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-13 01:39:26 +00:00
fixes from initial load testing
This commit is contained in:
@@ -435,7 +435,7 @@ class CallSession extends Emitter {
|
||||
|
||||
// need to allocate an endpoint
|
||||
try {
|
||||
if (!this.ms) this.ms = await this.getMS();
|
||||
if (!this.ms) this.ms = this.getMS();
|
||||
const ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
|
||||
ep.cs = this;
|
||||
this.ep = ep;
|
||||
@@ -485,7 +485,7 @@ class CallSession extends Emitter {
|
||||
* Hang up the call and free the media endpoint
|
||||
*/
|
||||
async _clearResources() {
|
||||
for (const resource of [this.dlg, this.ep, this.ms]) {
|
||||
for (const resource of [this.dlg, this.ep]) {
|
||||
try {
|
||||
if (resource && resource.connected) await resource.destroy();
|
||||
} catch (err) {
|
||||
@@ -505,12 +505,10 @@ class CallSession extends Emitter {
|
||||
/**
|
||||
* get a media server to use for this call
|
||||
*/
|
||||
async getMS() {
|
||||
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(fsOpts);
|
||||
this.ms = this.srf.locals.getFreeswitch();
|
||||
if (!this.ms) throw new Error('no available freeswitch');
|
||||
}
|
||||
return this.ms;
|
||||
}
|
||||
@@ -520,14 +518,13 @@ class CallSession extends Emitter {
|
||||
* the current media server and endpoint that are associated with this call
|
||||
*/
|
||||
async createOrRetrieveEpAndMs() {
|
||||
const mrf = this.srf.locals.mrf;
|
||||
if (this.ms && this.ep) return {ms: this.ms, ep: this.ep};
|
||||
|
||||
// get a media server
|
||||
if (!this.ms) {
|
||||
const fsOpts = this.srf.locals.getFreeswitch();
|
||||
if (!fsOpts) throw new Error('no available freeswitch');
|
||||
this.ms = await mrf.connect(fsOpts);
|
||||
const ms = this.srf.locals.getFreeswitch();
|
||||
if (!ms) throw new Error('no available freeswitch');
|
||||
this.ms = ms;
|
||||
}
|
||||
if (!this.ep) {
|
||||
this.ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
|
||||
|
||||
Reference in New Issue
Block a user