为什么我从 client.conferences.each() 得到未定义会议的列表?
Why do I get a list of undefined conferences from client.conferences.each()?
运行 Heroku 上的 Node/Twilio 应用程序。我想将一个参会者放入一个会议,然后获取该参会者所在会议的信息。
以下是我如何 return 将参与者加入会议的 Twiml:
//response parameter is a VoiceResponse
function addConferenceToResponse(response,params){
baseUrl=APP_URL+'ivr/conferenceControl';
console.log("addConferenceToResponse: baseUrl "+baseUrl);
//serializes the parameter array and adds it the the GET request
url=addArrayToGetRequest(baseUrl,params,"params");
const dial = response.dial({
action: url,
method: 'GET',
hangupOnStar: true
});
dial.conference(params.conferenceName,{
statusCallbackEvent:'start end join leave',
statusCallback:APP_URL+'ivr/statusChangeConference',
statusCallbackMethod:'GET',
waitUrl:waitUrl,
waitMethod:'GET'
});
return response.toString();
}
按照模型 here,我有一个函数可以 return 列出会议状态和 FriendlyNames:
function listConferences(){
client.conferences.each((conference) => {
console.log("list conferences: " + conference.status);
console.log("list conferences: " + conference.friendly_name);
})
}
我在会议的 StatusCallback 中这样调用:
router.get('/statusChangeConference',(req,res)=>{
status=req.query.StatusCallbackEvent;
if (status=="participant-join"){
handler.listConferences();
}
sendValue=doSomethingToGetASendValue();
if (sendValue!=null){
res.send(sendValue);
}
});
listConferences()
结束了 return 数百行:
2018-03-31T21:39:41.734717+00:00 app[web.1]: list conferences: completed
2018-03-31T21:39:41.734769+00:00 app[web.1]: list conferences: undefined
这意味着,我认为,它正在 returning 所有过去的会议,我猜现在不再有 FriendlyNames 了?但当前活动的会议未显示在此列表中。所以也许这个 StatusCallbackEvent 在 Twilio 有机会将会议输入到它的数据库之前被执行。
如何获取当前活动会议的属性?我想做的一件事是将所有剩余的会议参与者重定向到另一个 URL 如果他们中的一个人离开了,如果不能获得当前会议并做类似的事情,这似乎是不可能的:
client.conferences.each(conference=>{
conference.participants.each(participant=>{
client.calls(participant.CallSid).update({
//url redirect stuff here
});
});
});
但如果我无法获取当前活动的会议,我将无法执行此操作。
我不确定为什么,但是当我添加搜索选项时,我成功找到了我感兴趣的会议:[=11=]
exports.listConferences=function listConferences(friendlyName){
const opts = {status: 'in-progress',
friendlyName:friendlyName};
client.conferences.each(opts,(conference) => {
console.log("listing conference properties: ");
Object.entries(conference).forEach(
([key, value]) => console.log(key, value)
);
});
}
可能是之前在列表中出现了,只是在所有已完成的会议中没有发现它。
运行 Heroku 上的 Node/Twilio 应用程序。我想将一个参会者放入一个会议,然后获取该参会者所在会议的信息。
以下是我如何 return 将参与者加入会议的 Twiml:
//response parameter is a VoiceResponse
function addConferenceToResponse(response,params){
baseUrl=APP_URL+'ivr/conferenceControl';
console.log("addConferenceToResponse: baseUrl "+baseUrl);
//serializes the parameter array and adds it the the GET request
url=addArrayToGetRequest(baseUrl,params,"params");
const dial = response.dial({
action: url,
method: 'GET',
hangupOnStar: true
});
dial.conference(params.conferenceName,{
statusCallbackEvent:'start end join leave',
statusCallback:APP_URL+'ivr/statusChangeConference',
statusCallbackMethod:'GET',
waitUrl:waitUrl,
waitMethod:'GET'
});
return response.toString();
}
按照模型 here,我有一个函数可以 return 列出会议状态和 FriendlyNames:
function listConferences(){
client.conferences.each((conference) => {
console.log("list conferences: " + conference.status);
console.log("list conferences: " + conference.friendly_name);
})
}
我在会议的 StatusCallback 中这样调用:
router.get('/statusChangeConference',(req,res)=>{
status=req.query.StatusCallbackEvent;
if (status=="participant-join"){
handler.listConferences();
}
sendValue=doSomethingToGetASendValue();
if (sendValue!=null){
res.send(sendValue);
}
});
listConferences()
结束了 return 数百行:
2018-03-31T21:39:41.734717+00:00 app[web.1]: list conferences: completed
2018-03-31T21:39:41.734769+00:00 app[web.1]: list conferences: undefined
这意味着,我认为,它正在 returning 所有过去的会议,我猜现在不再有 FriendlyNames 了?但当前活动的会议未显示在此列表中。所以也许这个 StatusCallbackEvent 在 Twilio 有机会将会议输入到它的数据库之前被执行。
如何获取当前活动会议的属性?我想做的一件事是将所有剩余的会议参与者重定向到另一个 URL 如果他们中的一个人离开了,如果不能获得当前会议并做类似的事情,这似乎是不可能的:
client.conferences.each(conference=>{
conference.participants.each(participant=>{
client.calls(participant.CallSid).update({
//url redirect stuff here
});
});
});
但如果我无法获取当前活动的会议,我将无法执行此操作。
我不确定为什么,但是当我添加搜索选项时,我成功找到了我感兴趣的会议:[=11=]
exports.listConferences=function listConferences(friendlyName){
const opts = {status: 'in-progress',
friendlyName:friendlyName};
client.conferences.each(opts,(conference) => {
console.log("listing conference properties: ");
Object.entries(conference).forEach(
([key, value]) => console.log(key, value)
);
});
}
可能是之前在列表中出现了,只是在所有已完成的会议中没有发现它。