From ac3d0858f67599ac3c0cd9c5e7047f54e70c7f35 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Thu, 10 Dec 2015 23:57:44 +1100 Subject: [PATCH] Adds call support --- JitsiConference.js | 51 ++++++- JitsiConferenceEvents.js | 6 +- doc/example/example.js | 18 ++- lib-jitsi-meet.js | 271 +++++++++++++++++++++++++---------- modules/xmpp/ChatRoom.js | 46 +++++- modules/xmpp/recording.js | 15 +- modules/xmpp/strophe.rayo.js | 145 +++++++++++-------- service/xmpp/XMPPEvents.js | 6 +- 8 files changed, 408 insertions(+), 150 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index 6b0d18ad9..6ca4b1b46 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -454,6 +454,45 @@ JitsiConference.prototype.toggleRecording = function (token) { reject(new Error("The conference is not created yet!"))}); } +/** + * Dials a number. + * @param number the number + */ +JitsiConference.prototype.dial = function (number) { + if(this.room) + return this.room.dial(number); + return new Promise(function(resolve, reject){ + reject(new Error("The conference is not created yet!"))}); +} + +/** + * Hangup an existing call + */ +JitsiConference.prototype.hangup = function () { + if(this.room) + return this.room.hangup(); + return new Promise(function(resolve, reject){ + reject(new Error("The conference is not created yet!"))}); +} + +/** + * Returns the phone number for joining the conference. + */ +JitsiConference.prototype.getPhoneNumber = function () { + if(this.room) + return this.room.getPhoneNumber(); + return null; +} + +/** + * Returns the pin for joining the conference with phone. + */ +JitsiConference.prototype.getPhonePin = function () { + if(this.room) + return this.room.getPhonePin(); + return null; +} + /** * Setups the listeners needed for the conference. * @param conference the conference @@ -495,8 +534,16 @@ function setupListeners(conference) { conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () { conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED); }); - conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, function () { - conference.eventEmitter.emit(JitsiConferenceEvents.RECORDING_STATE_CHANGED); + + conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, + function () { + conference.eventEmitter.emit( + JitsiConferenceEvents.RECORDING_STATE_CHANGED); + }); + + conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () { + conference.eventEmitter.emit( + JitsiConferenceEvents.PHONE_NUMBER_CHANGED); }); conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () { diff --git a/JitsiConferenceEvents.js b/JitsiConferenceEvents.js index 3ea10fb95..72c0596fe 100644 --- a/JitsiConferenceEvents.js +++ b/JitsiConferenceEvents.js @@ -87,7 +87,11 @@ var JitsiConferenceEvents = { /** * Indicates that recording state changed. */ - RECORDING_STATE_CHANGED: "conference.recordingStateChanged" + RECORDING_STATE_CHANGED: "conference.recordingStateChanged", + /** + * Indicates that phone number changed. + */ + PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged" }; module.exports = JitsiConferenceEvents; diff --git a/doc/example/example.js b/doc/example/example.js index aa991e86e..f5eeda052 100644 --- a/doc/example/example.js +++ b/doc/example/example.js @@ -1,5 +1,7 @@ var options = { hosts: { + call_control: "callcontrol.chaos.hipchat.me", + focus: "focus.chaos.hipchat.me", domain: 'chaos.hipchat.me', muc: 'conference.chaos.hipchat.me', // FIXME: use XEP-0030 bridge: 'jitsi-videobridge.chaos.hipchat.me', // FIXME: use XEP-0030 @@ -37,8 +39,8 @@ function onLocalTracks(tracks) $("body").append("