0

I'm coding a Click-to-Call app using Twilio with Node.js. The app works, and it's functional, but I'm having some issues when ending calls.

I've tryed to retrive all calls and updated their status to "completed". And the calls seem to have ended, BUT on my phone, I still hear the disconnect tones (Tu-tu-tu tu-tu-tu tu-tu-tu...).

This is executed when one of both phones manually hangs up the call:

   client.calls.list(function(err, data) {
        data.calls.forEach(function(call) {
            client.calls(call.sid).update({
                status: "completed"
            }, function(err, call) {
            });
        });
    });

I'm aware it's kinda exagerated, but I'm a little frustrated.

So my question is, is it possible to absolutely hangup both click-to-call calls so I don't have to press the button on my actual phone?

Cœur
  • 37,241
  • 25
  • 195
  • 267
alejandromav
  • 933
  • 1
  • 11
  • 24

1 Answers1

1

Have you attempted to use the disconnect function?

  Twilio.Device.disconnect(function (conn) {
      $("#log").text("Call ended");
   });

https://www.twilio.com/docs/quickstart/php/client/hangup

StevenDStanton
  • 841
  • 1
  • 7
  • 23
  • As far as I know, "Twilio" is the JS client. However, Node.js uses a different module, which hasn't got that function. Your answer works in client side JS, but not in a Node.js app. Thanks anyway. – alejandromav Mar 11 '15 at 15:03
  • I did not realize you actually wanted to initiate the hangup from the server side. I will look into this. You can probably use cURL to do it but I am not sure the exact command. I will try to get you an update tonight. – StevenDStanton Mar 12 '15 at 18:26