mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
add sms messaging support
This commit is contained in:
@@ -44,6 +44,14 @@ class CallInfo {
|
||||
this.callStatus = CallStatus.Trying,
|
||||
this.sipStatus = 100;
|
||||
}
|
||||
else if (this.direction === CallDirection.None) {
|
||||
// outbound SMS
|
||||
const {messageSid, accountSid, applicationSid, res} = opts;
|
||||
this.messageSid = messageSid;
|
||||
this.accountSid = accountSid;
|
||||
this.applicationSid = applicationSid;
|
||||
this.res = res;
|
||||
}
|
||||
else {
|
||||
// outbound call triggered by REST
|
||||
const {req, accountSid, applicationSid, to, tag} = opts;
|
||||
|
||||
@@ -34,18 +34,20 @@ class CallSession extends Emitter {
|
||||
this.srf = srf;
|
||||
this.callInfo = callInfo;
|
||||
this.tasks = tasks;
|
||||
|
||||
this.updateCallStatus = srf.locals.dbHelpers.updateCallStatus;
|
||||
this.serviceUrl = srf.locals.serviceUrl;
|
||||
|
||||
this.taskIdx = 0;
|
||||
this.stackIdx = 0;
|
||||
this.callGone = false;
|
||||
|
||||
this.tmpFiles = new Set();
|
||||
|
||||
// if this is a ConfirmSession
|
||||
if (!this.isConfirmCallSession) sessionTracker.add(this.callSid, this);
|
||||
if (!this.isSmsCallSession) {
|
||||
this.updateCallStatus = srf.locals.dbHelpers.updateCallStatus;
|
||||
this.serviceUrl = srf.locals.serviceUrl;
|
||||
}
|
||||
|
||||
if (!this.isConfirmCallSession && !this.isSmsCallSession) {
|
||||
sessionTracker.add(this.callSid, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +68,7 @@ class CallSession extends Emitter {
|
||||
* SIP call-id for the call
|
||||
*/
|
||||
get callId() {
|
||||
return this.callInfo.direction;
|
||||
return this.callInfo.callId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,6 +168,13 @@ class CallSession extends Emitter {
|
||||
return this.constructor.name === 'ConfirmCallSession';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if this session is a SmsCallSession
|
||||
*/
|
||||
get isSmsCallSession() {
|
||||
return this.constructor.name === 'SmsCallSession';
|
||||
}
|
||||
|
||||
/**
|
||||
* execute the tasks in the CallSession. The tasks are executed in sequence until
|
||||
* they complete, or the caller hangs up.
|
||||
@@ -201,7 +210,7 @@ class CallSession extends Emitter {
|
||||
this._onTasksDone();
|
||||
this._clearResources();
|
||||
|
||||
if (!this.isConfirmCallSession) sessionTracker.remove(this.callSid);
|
||||
if (!this.isConfirmCallSession && !this.isSmsCallSession) sessionTracker.remove(this.callSid);
|
||||
}
|
||||
|
||||
trackTmpFile(path) {
|
||||
|
||||
22
lib/session/sms-call-session.js
Normal file
22
lib/session/sms-call-session.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const CallSession = require('./call-session');
|
||||
|
||||
/**
|
||||
* @classdesc Subclass of CallSession. Represents a CallSession
|
||||
* that is established for the purpose of sending an outbound SMS
|
||||
* @extends CallSession
|
||||
|
||||
*/
|
||||
class SmsCallSession extends CallSession {
|
||||
constructor({logger, application, srf, tasks, callInfo}) {
|
||||
super({
|
||||
logger,
|
||||
application,
|
||||
srf,
|
||||
tasks,
|
||||
callInfo
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SmsCallSession;
|
||||
Reference in New Issue
Block a user