我有一个系统,可以进行浏览器到浏览器的调用。
当来电时,使用接受,他们可以毫无问题地进行通信! Hooray for twilio。
所以现在我们有两个人 - 接听电话的人(让我们称他们为接收者)和打电话的人(让他们称之为拨号器)
然后接收器有一个叫做保持状态的按钮。单击此按钮时,它会将接收器重定向到您保持呼叫的循环消息,并将拨号器重定向到队列 - 他们可以收听一些时髦的音乐。
如果再次单击它,Receiver将拨打队列并获取呼叫者。这也很有效,他们可以再次沟通。
但是.....如果我把拨号器放回队列中就行了,但是当我通过修改Calls update方法检索它并将其重定向到与呼叫未更新之前相同的部分时。 / p>
这不会引发任何错误。这几乎就像twilio甚至没有尝试将调用重定向到URL,因为日志没有返回任何内容。由于没有错误,我的应用程序认为一切正常。
这是否会发生这种情况?有限制吗?
要清楚这是第一次工作 - 完美。只是不是下一次,只有在检索电话时。
这是Call实例上的update命令的问题。
我使用Laravel作为我的框架
这是我的Routes.php
// Hold music and Client Message
Route::post('voice/queue/music', ['uses' => 'API\VoiceController@queueHoldMusic']);
Route::post('voice/queue/client-message', ['uses' => 'API\VoiceController@clientHoldMusic']);
// Routes containing Twiml XML
Route::post('voice/inbound/enqueue-call', ['uses' => 'API\Voice\InboundCallHoldController@placeInboundCallOnHold']);
Route::post('voice/inbound/dequeue-call', ['uses' => 'API\Voice\InboundCallHoldController@dialHeldInboundCall']);
// Place Outbound Call on Hold
Route::post('inbound/enqueue', ['uses' => 'API\Voice\InboundCallHoldController@holdInboundCall']);
Route::post('inbound/dequeue', ['uses' => 'API\Voice\InboundCallHoldController@getInboundCallOnHold']);
这是我的InboundCallHoldController.php
class InboundCallHoldController extends Controller
{
public function placeInboundCallOnHold(Request $request){
$CallSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$response = new Twiml();
$queue = 'call-hold:'.$CallSid;
Log::info("---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller ".$CallSid." to ".$queue);
$response->enqueue($queue, ['waitUrl' => env("API_URL").'/api/voice/queue/music']);
return response($response)->header('Content-Type', 'text/xml');
}
public function dialHeldInboundCall(Request $request){
$callSid = $request['ParentCallSid'] !== null ? $request['ParentCallSid'] : null;
$response = new Twiml();
$dial = $response->dial();
$queueName = 'call-hold:'.$callSid;
Log::info("---> Inbound Call | dialHeldInboundCall --> Dialing a queue to get a caller ".$queueName);
$dial->queue($queueName);
$response->redirect(env('API_URL')."/api/voice/queue/client-message");
return response($response)->header('Content-Type', 'text/xml');
}
public function getInboundCallOnHold(Request $request){
$callSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$account = Account::where("twilio_sid", "TWILIO_ACCOUNT_SID")->first();
$client = new Client($account->twilio_sid, $account->twilio_auth_token);
Log::info("---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller ".$callSid . " to Queue");
$call = $client->calls($callSid)->fetch();
$client->calls($call->sid)->update([
"url" => env('API_URL')."/api/voice/inbound/dequeue-call",
"method" => "POST"
]);
Log::info("---> Inbound Call | getInboundCallOnHold --> ".$callSid . " status is now ".$call->status);
return response([
"status" => "fetched-inbound-call",
"success" => true
], 200);
}
public function holdInboundCall(Request $request){
$callSid = $request['CallSid'] !== null ? $request['CallSid'] : null;
$account = Account::where("twilio_sid", "TWILIO_ACCOUNT_SID")->first();
$client = new Client($account->twilio_sid, $account->twilio_auth_token);
Log::info("---> Inbound Call | Hold Initiated");
$call = $client->calls($callSid)->fetch();
$parentCall = $client->calls($call->parentCallSid)->fetch();
if($parentCall->status === "in-progress" and $call->status == "in-progress"){
// find the child - this is the receiver - Play the hold music
Log::info("---> Inbound Call | holdInboundCall --> Redirect Receiver ".$call->sid . " to wait message");
$call->update([
"url" => env('API_URL')."/api/voice/queue/client-message",
"method" => "POST"
]);
// find the parent - this is the inbound caller - Add them to a queue
Log::info("---> Inbound Call | holdInboundCall --> Redirect Inbound Caller ".$parentCall->sid . " to queue");
$parentCall->update([
"url" => env('API_URL')."/api/voice/inbound/enqueue-call",
"method" => "POST"
]);
return response([
"status" => "on-hold-inbound",
"success" => true
], 200);
}
return response()->json(["call_hold_failed" => ["A call not be placed on hold until it has been answered"]], 422);
}
}
这是第二次更新后没有发生的情况。
$client->calls($call->sid)->update([
"url" => env('API_URL')."/api/voice/inbound/dequeue-call",
"method" => "POST"
]);
这很奇怪,因为这是失败之前的过程;
正如我所说,没有错误被抛出。
我使用Javascript调用以下网址
来调用它们// Place Outbound Call on Hold
Route::post('inbound/enqueue', ['uses' => 'API\Voice\InboundCallHoldController@holdInboundCall']);
Route::post('inbound/dequeue', ['uses' => 'API\Voice\InboundCallHoldController@getInboundCallOnHold']);
这是输出的日志;
[2017-09-04 13:42:47] local.INFO: ---> Inbound Call | Hold Initiated
[2017-09-04 13:42:47] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Receiver CA784af9a0419cde8dc3ab2379ad93e5b2 to wait message
[2017-09-04 13:42:48] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Inbound Caller CA3c31e8169647a7d90455058ce7bfa70f to queue
[2017-09-04 13:42:49] local.INFO: ---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller CA3c31e8169647a7d90455058ce7bfa70f to call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:09] local.INFO: ---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller CA784af9a0419cde8dc3ab2379ad93e5b2 to Queue
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | getInboundCallOnHold --> CA784af9a0419cde8dc3ab2379ad93e5b2 status is now in-progress
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | dialHeldInboundCall --> Dialing a queue to get a caller call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:10] local.INFO: ---> Inbound Call | dialHeldInboundCall --> Call Sid is CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:43:36] local.INFO: ---> Inbound Call | Hold Initiated
[2017-09-04 13:43:37] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Receiver CA784af9a0419cde8dc3ab2379ad93e5b2 to wait message
[2017-09-04 13:43:43] local.INFO: ---> Inbound Call | holdInboundCall --> Redirect Inbound Caller CA3c31e8169647a7d90455058ce7bfa70f to queue
[2017-09-04 13:43:44] local.INFO: ---> Inbound Call | placeInboundCallOnHold --> Enqueuing Caller CA3c31e8169647a7d90455058ce7bfa70f to call-hold:CA3c31e8169647a7d90455058ce7bfa70f
[2017-09-04 13:44:06] local.INFO: ---> Inbound Call | getInboundCallOnHold --> Updating Live call and redirecting Caller CA784af9a0419cde8dc3ab2379ad93e5b2 to Queue
[2017-09-04 13:44:07] local.INFO: ---> Inbound Call | getInboundCallOnHold --> CA784af9a0419cde8dc3ab2379ad93e5b2 status is now in-progress
答案 0 :(得分:1)
由于OnHoldStatus是通过PHP设置的,并且它看起来不像你在代码中进行任何序列化,(在多用户高级用户中使用的会话跟踪)
退出OnHold条件IE时,是否会清除PHP全局或其他服务器端变量:在退出之前添加代码以清除PHP
或者说另一种方式是服务器上的PHP变量。它们已经设置为旧的最后状态。