123456789101112131415161718192021222324252627282930313233 |
- $(document).ready(function(){
- Twilio.Device.setup("<?php echo $token; ?>");
- $("#call").click(function() {
- Twilio.Device.connect();
- });
- $("#hangup").click(function() {
- Twilio.Device.disconnectAll();
- });
- Twilio.Device.ready(function (device) {
- $('#status').text('Ready to start call');
- });
- Twilio.Device.offline(function (device) {
- $('#status').text('Offline');
- });
- Twilio.Device.error(function (error) {
- $('#status').text(error);
- });
- Twilio.Device.connect(function (conn) {
- $('#status').text("Successfully established call");
- toggleCallStatus();
- });
- Twilio.Device.disconnect(function (conn) {
- $('#status').text("Call ended");
- toggleCallStatus();
- });
- Twilio.Device.incoming(function (conn) {
- conn.accept();
- });
- function toggleCallStatus(){
- $('#call').toggle();
- $('#hangup').toggle();
- }
- });
|