hristoterezov 10 роки тому
джерело
коміт
5cfd0b39d4

+ 49
- 2
JitsiConference.js Переглянути файл

@@ -454,6 +454,45 @@ JitsiConference.prototype.toggleRecording = function (token) {
454 454
         reject(new Error("The conference is not created yet!"))});
455 455
 }
456 456
 
457
+/**
458
+ * Dials a number.
459
+ * @param number the number
460
+ */
461
+JitsiConference.prototype.dial = function (number) {
462
+    if(this.room)
463
+        return this.room.dial(number);
464
+    return new Promise(function(resolve, reject){
465
+        reject(new Error("The conference is not created yet!"))});
466
+}
467
+
468
+/**
469
+ * Hangup an existing call
470
+ */
471
+JitsiConference.prototype.hangup = function () {
472
+    if(this.room)
473
+        return this.room.hangup();
474
+    return new Promise(function(resolve, reject){
475
+        reject(new Error("The conference is not created yet!"))});
476
+}
477
+
478
+/**
479
+ * Returns the phone number for joining the conference.
480
+ */
481
+JitsiConference.prototype.getPhoneNumber = function () {
482
+    if(this.room)
483
+        return this.room.getPhoneNumber();
484
+    return null;
485
+}
486
+
487
+/**
488
+ * Returns the pin for joining the conference with phone.
489
+ */
490
+JitsiConference.prototype.getPhonePin = function () {
491
+    if(this.room)
492
+        return this.room.getPhonePin();
493
+    return null;
494
+}
495
+
457 496
 /**
458 497
  * Setups the listeners needed for the conference.
459 498
  * @param conference the conference
@@ -495,8 +534,16 @@ function setupListeners(conference) {
495 534
     conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
496 535
         conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
497 536
     });
498
-    conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, function () {
499
-        conference.eventEmitter.emit(JitsiConferenceEvents.RECORDING_STATE_CHANGED);
537
+
538
+    conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED,
539
+        function () {
540
+            conference.eventEmitter.emit(
541
+                JitsiConferenceEvents.RECORDING_STATE_CHANGED);
542
+        });
543
+
544
+    conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
545
+        conference.eventEmitter.emit(
546
+            JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
500 547
     });
501 548
 
502 549
     conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {

+ 5
- 1
JitsiConferenceEvents.js Переглянути файл

@@ -87,7 +87,11 @@ var JitsiConferenceEvents = {
87 87
     /**
88 88
      * Indicates that recording state changed.
89 89
      */
90
-    RECORDING_STATE_CHANGED: "conference.recordingStateChanged"
90
+    RECORDING_STATE_CHANGED: "conference.recordingStateChanged",
91
+    /**
92
+     * Indicates that phone number changed.
93
+     */
94
+    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
91 95
 };
92 96
 
93 97
 module.exports = JitsiConferenceEvents;

+ 13
- 5
doc/example/example.js Переглянути файл

@@ -1,5 +1,7 @@
1 1
 var options = {
2 2
     hosts: {
3
+        call_control: "callcontrol.chaos.hipchat.me",
4
+        focus: "focus.chaos.hipchat.me",
3 5
         domain: 'chaos.hipchat.me',
4 6
         muc: 'conference.chaos.hipchat.me', // FIXME: use XEP-0030
5 7
         bridge: 'jitsi-videobridge.chaos.hipchat.me', // FIXME: use XEP-0030
@@ -40,8 +42,8 @@ function onLocalTracks(tracks)
40 42
             $("body").append("<video autoplay='1' id='localVideo" + i + "' />");
41 43
             localTracks[i].attach($("#localVideo" + i ));
42 44
         } else {
43
-            $("body").append("<audio autoplay='1' id='localAudio" + i + "' />");
44
-            localTracks[i].attach($("#localAudio" + i ));
45
+            // $("body").append("<audio autoplay='1' id='localAudio" + i + "' />");
46
+            // localTracks[i].attach($("#localAudio" + i ));
45 47
         }
46 48
         if(isJoined)
47 49
             room.addTrack(localTracks[i]);
@@ -91,6 +93,7 @@ function onConferenceJoined () {
91 93
 }
92 94
 
93 95
 function onUserLeft(id) {
96
+    console.log("user left");
94 97
     if(!remoteTracks[id])
95 98
         return;
96 99
     var tracks = remoteTracks[id];
@@ -102,13 +105,13 @@ function onUserLeft(id) {
102 105
  * That function is called when connection is established successfully
103 106
  */
104 107
 function onConnectionSuccess(){
105
-    room = connection.initJitsiConference("conference2", confOptions);
108
+    room = connection.initJitsiConference("conference6", confOptions);
106 109
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
107 110
     room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, function (track) {
108 111
         console.log("track removed!!!" + track);
109 112
     });
110 113
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
111
-    room.on(JitsiMeetJS.events.conference.USER_JOINED, function(id){ remoteTracks[id] = [];});
114
+    room.on(JitsiMeetJS.events.conference.USER_JOINED, function(id){ console.log("user join");remoteTracks[id] = [];});
112 115
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
113 116
     room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, function (track) {
114 117
         console.log(track.getType() + " - " + track.isMuted());
@@ -124,7 +127,12 @@ function onConnectionSuccess(){
124 127
         console.log(room.isRecordingSupported() + " - " +
125 128
             room.getRecordingState() + " - " +
126 129
             room.getRecordingURL());
127
-    })
130
+    });
131
+    room.on(JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED, function () {
132
+        console.log(
133
+            room.getPhoneNumber() + " - " +
134
+            room.getPhonePin());
135
+    });
128 136
     room.join();
129 137
 };
130 138
 

+ 198
- 73
lib-jitsi-meet.js Переглянути файл

@@ -456,6 +456,45 @@ JitsiConference.prototype.toggleRecording = function (token) {
456 456
         reject(new Error("The conference is not created yet!"))});
457 457
 }
458 458
 
459
+/**
460
+ * Dials a number.
461
+ * @param number the number
462
+ */
463
+JitsiConference.prototype.dial = function (number) {
464
+    if(this.room)
465
+        return this.room.dial(number);
466
+    return new Promise(function(resolve, reject){
467
+        reject(new Error("The conference is not created yet!"))});
468
+}
469
+
470
+/**
471
+ * Hangup an existing call
472
+ */
473
+JitsiConference.prototype.hangup = function () {
474
+    if(this.room)
475
+        return this.room.hangup();
476
+    return new Promise(function(resolve, reject){
477
+        reject(new Error("The conference is not created yet!"))});
478
+}
479
+
480
+/**
481
+ * Returns the phone number for joining the conference.
482
+ */
483
+JitsiConference.prototype.getPhoneNumber = function () {
484
+    if(this.room)
485
+        return this.room.getPhoneNumber();
486
+    return null;
487
+}
488
+
489
+/**
490
+ * Returns the pin for joining the conference with phone.
491
+ */
492
+JitsiConference.prototype.getPhonePin = function () {
493
+    if(this.room)
494
+        return this.room.getPhonePin();
495
+    return null;
496
+}
497
+
459 498
 /**
460 499
  * Setups the listeners needed for the conference.
461 500
  * @param conference the conference
@@ -497,8 +536,16 @@ function setupListeners(conference) {
497 536
     conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
498 537
         conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
499 538
     });
500
-    conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED, function () {
501
-        conference.eventEmitter.emit(JitsiConferenceEvents.RECORDING_STATE_CHANGED);
539
+
540
+    conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED,
541
+        function () {
542
+            conference.eventEmitter.emit(
543
+                JitsiConferenceEvents.RECORDING_STATE_CHANGED);
544
+        });
545
+
546
+    conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
547
+        conference.eventEmitter.emit(
548
+            JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
502 549
     });
503 550
 
504 551
     conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
@@ -666,7 +713,11 @@ var JitsiConferenceEvents = {
666 713
     /**
667 714
      * Indicates that recording state changed.
668 715
      */
669
-    RECORDING_STATE_CHANGED: "conference.recordingStateChanged"
716
+    RECORDING_STATE_CHANGED: "conference.recordingStateChanged",
717
+    /**
718
+     * Indicates that phone number changed.
719
+     */
720
+    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
670 721
 };
671 722
 
672 723
 module.exports = JitsiConferenceEvents;
@@ -5830,6 +5881,8 @@ function ChatRoom(connection, jid, password, XMPP, options) {
5830 5881
     this.session = null;
5831 5882
     var self = this;
5832 5883
     this.lastPresences = {};
5884
+    this.phoneNumber = null;
5885
+    this.phonePin = null;
5833 5886
 }
5834 5887
 
5835 5888
 ChatRoom.prototype.initPresenceMap = function () {
@@ -5947,6 +6000,7 @@ ChatRoom.prototype.createNonAnonymousRoom = function () {
5947 6000
 };
5948 6001
 
5949 6002
 ChatRoom.prototype.onPresence = function (pres) {
6003
+    console.log(pres);
5950 6004
     var from = pres.getAttribute('from');
5951 6005
     // Parse roles.
5952 6006
     var member = {};
@@ -6000,6 +6054,16 @@ ChatRoom.prototype.onPresence = function (pres) {
6000 6054
                 break;
6001 6055
             case "jibri-recording-status":
6002 6056
                 var jibri = node;
6057
+                break;
6058
+            case "call-control":
6059
+                console.log(pres);
6060
+                var att = node.attributes;
6061
+                if(!att)
6062
+                    break;
6063
+                this.phoneNumber = att.phone || null;
6064
+                this.phonePin = att.pin || null;
6065
+                this.eventEmitter.emit(XMPPEvents.PHONE_NUMBER_CHANGED);
6066
+                break;
6003 6067
             default :
6004 6068
                 this.processNode(node, from);
6005 6069
         }
@@ -6440,13 +6504,44 @@ ChatRoom.prototype.getRecordingURL = function () {
6440 6504
  * @param token token for authentication
6441 6505
  */
6442 6506
 ChatRoom.prototype.toggleRecording = function (token) {
6443
-    if(this.recording/** && this.isModerator()**/)
6507
+    if(this.recording)
6444 6508
         return this.recording.toggleRecording(token);
6445 6509
 
6446 6510
     return new Promise(function(resolve, reject){
6447 6511
         reject(new Error("The conference is not created yet!"))});
6448 6512
 }
6449 6513
 
6514
+/**
6515
+ * Dials a number.
6516
+ * @param number the number
6517
+ */
6518
+ChatRoom.prototype.dial = function (number) {
6519
+    return this.connection.rayo.dial(number, "fromnumber",
6520
+        Strophe.getNodeFromJid(this.myroomjid), this.password,
6521
+        this.focusMucJid);
6522
+}
6523
+
6524
+/**
6525
+ * Hangup an existing call
6526
+ */
6527
+ChatRoom.prototype.hangup = function () {
6528
+    return this.connection.rayo.hangup();
6529
+}
6530
+
6531
+/**
6532
+ * Returns the phone number for joining the conference.
6533
+ */
6534
+ChatRoom.prototype.getPhoneNumber = function () {
6535
+    return this.phoneNumber;
6536
+}
6537
+
6538
+/**
6539
+ * Returns the pin for joining the conference with phone.
6540
+ */
6541
+ChatRoom.prototype.getPhonePin = function () {
6542
+    return this.phonePin;
6543
+}
6544
+
6450 6545
 module.exports = ChatRoom;
6451 6546
 
6452 6547
 }).call(this,"/modules/xmpp/ChatRoom.js")
@@ -10601,9 +10696,11 @@ module.exports = Moderator;
10601 10696
 
10602 10697
 }).call(this,"/modules/xmpp/moderator.js")
10603 10698
 },{"../../service/authentication/AuthenticationEvents":87,"../../service/xmpp/XMPPEvents":91,"../settings/Settings":21,"jitsi-meet-logger":48}],35:[function(require,module,exports){
10699
+(function (__filename){
10604 10700
 /* global $, $iq, config, connection, focusMucJid, messageHandler,
10605 10701
    Toolbar, Util, Promise */
10606 10702
 var XMPPEvents = require("../../service/XMPP/XMPPEvents");
10703
+var logger = require("jitsi-meet-logger").getLogger(__filename);
10607 10704
 
10608 10705
 function Recording(ee, connection, focusMucJid) {
10609 10706
     this.eventEmitter = ee;
@@ -10643,7 +10740,7 @@ Recording.prototype.setRecording = function (state, streamId, callback,
10643 10740
             streamid: streamId
10644 10741
         }).up();
10645 10742
 
10646
-    console.log('Set jibri recording: '+state, iq);
10743
+    logger.log('Set jibri recording: '+state, iq);
10647 10744
 
10648 10745
     this.connection.sendIQ(
10649 10746
         iq,
@@ -10652,7 +10749,7 @@ Recording.prototype.setRecording = function (state, streamId, callback,
10652 10749
             $(result).find('jibri').attr('url'));
10653 10750
         },
10654 10751
         function (error) {
10655
-            console.log('Failed to start recording, error: ', error);
10752
+            logger.log('Failed to start recording, error: ', error);
10656 10753
             errCallback(error);
10657 10754
         });
10658 10755
 };
@@ -10661,8 +10758,14 @@ Recording.prototype.toggleRecording = function (token) {
10661 10758
     var self = this;
10662 10759
     return new Promise(function(resolve, reject) {
10663 10760
         if (!token) {
10664
-            console.error("No token passed!");
10665 10761
             reject(new Error("No token passed!"));
10762
+            logger.error("No token passed!");
10763
+            return;
10764
+        }
10765
+        if(self.state === "on") {
10766
+            reject(new Error("Recording is already started!"));
10767
+            logger.error("Recording is already started!");
10768
+            return;
10666 10769
         }
10667 10770
 
10668 10771
         var oldState = self.state;
@@ -10671,7 +10774,7 @@ Recording.prototype.toggleRecording = function (token) {
10671 10774
         self.setRecording(newState,
10672 10775
             token,
10673 10776
             function (state, url) {
10674
-                console.log("New recording state: ", state);
10777
+                logger.log("New recording state: ", state);
10675 10778
                 if (state && state !== oldState) {
10676 10779
                     self.state = state;
10677 10780
                     self.url = url;
@@ -10711,7 +10814,8 @@ Recording.prototype.getURL = function () {
10711 10814
 
10712 10815
 module.exports = Recording;
10713 10816
 
10714
-},{"../../service/XMPP/XMPPEvents":86}],36:[function(require,module,exports){
10817
+}).call(this,"/modules/xmpp/recording.js")
10818
+},{"../../service/XMPP/XMPPEvents":86,"jitsi-meet-logger":48}],36:[function(require,module,exports){
10715 10819
 (function (__filename){
10716 10820
 /* jshint -W117 */
10717 10821
 /* a simple MUC connection plugin
@@ -11270,85 +11374,102 @@ module.exports = function() {
11270 11374
                 }
11271 11375
 
11272 11376
                 this.connection.addHandler(
11273
-                    this.onRayo.bind(this),
11274
-                    this.RAYO_XMLNS, 'iq', 'set', null, null);
11377
+                    this.onRayo.bind(this), this.RAYO_XMLNS, 'iq', 'set',
11378
+                    null, null);
11275 11379
             },
11276 11380
             onRayo: function (iq) {
11277 11381
                 logger.info("Rayo IQ", iq);
11278 11382
             },
11279
-            dial: function (to, from, roomName, roomPass) {
11383
+            dial: function (to, from, roomName, roomPass, focusMucJid) {
11280 11384
                 var self = this;
11281
-                var req = $iq(
11282
-                    {
11283
-                        type: 'set',
11284
-                        to: this.connection.emuc.focusMucJid
11385
+                return new Promise(function (resolve, reject) {
11386
+                    if(self.call_resource) {
11387
+                        reject(new Error("There is already started call!"));
11388
+                        return;
11285 11389
                     }
11286
-                );
11287
-                req.c('dial',
11288
-                    {
11289
-                        xmlns: this.RAYO_XMLNS,
11290
-                        to: to,
11291
-                        from: from
11292
-                    });
11293
-                req.c('header',
11294
-                    {
11295
-                        name: 'JvbRoomName',
11296
-                        value: roomName
11297
-                    }).up();
11298
-
11299
-                if (roomPass !== null && roomPass.length) {
11300
-
11390
+                    if(!focusMucJid) {
11391
+                        reject(new Error("Internal error!"));
11392
+                        return;
11393
+                    }
11394
+                    var req = $iq(
11395
+                        {
11396
+                            type: 'set',
11397
+                            to: focusMucJid
11398
+                        }
11399
+                    );
11400
+                    req.c('dial',
11401
+                        {
11402
+                            xmlns: self.RAYO_XMLNS,
11403
+                            to: to,
11404
+                            from: from
11405
+                        });
11301 11406
                     req.c('header',
11302 11407
                         {
11303
-                            name: 'JvbRoomPassword',
11304
-                            value: roomPass
11408
+                            name: 'JvbRoomName',
11409
+                            value: roomName
11305 11410
                         }).up();
11306
-                }
11307 11411
 
11308
-                this.connection.sendIQ(
11309
-                    req,
11310
-                    function (result) {
11311
-                        logger.info('Dial result ', result);
11412
+                    if (roomPass !== null && roomPass.length) {
11312 11413
 
11313
-                        var resource = $(result).find('ref').attr('uri');
11314
-                        this.call_resource = resource.substr('xmpp:'.length);
11315
-                        logger.info(
11316
-                            "Received call resource: " + this.call_resource);
11317
-                    },
11318
-                    function (error) {
11319
-                        logger.info('Dial error ', error);
11414
+                        req.c('header',
11415
+                            {
11416
+                                name: 'JvbRoomPassword',
11417
+                                value: roomPass
11418
+                            }).up();
11320 11419
                     }
11321
-                );
11322
-            },
11323
-            hang_up: function () {
11324
-                if (!this.call_resource) {
11325
-                    logger.warn("No call in progress");
11326
-                    return;
11327
-                }
11328 11420
 
11421
+                    self.connection.sendIQ(
11422
+                        req,
11423
+                        function (result) {
11424
+                            logger.info('Dial result ', result);
11425
+
11426
+                            var resource = $(result).find('ref').attr('uri');
11427
+                            self.call_resource = resource.substr('xmpp:'.length);
11428
+                            logger.info(
11429
+                                "Received call resource: " + self.call_resource);
11430
+                            resolve();
11431
+                        },
11432
+                        function (error) {
11433
+                            logger.info('Dial error ', error);
11434
+                            reject(error);
11435
+                        }
11436
+                    );
11437
+                });
11438
+            },
11439
+            hangup: function () {
11329 11440
                 var self = this;
11330
-                var req = $iq(
11331
-                    {
11332
-                        type: 'set',
11333
-                        to: this.call_resource
11441
+                return new Promise(function (resolve, reject) {
11442
+                    if (!self.call_resource) {
11443
+                        reject(new Error("No call in progress"));
11444
+                        logger.warn("No call in progress");
11445
+                        return;
11334 11446
                     }
11335
-                );
11336
-                req.c('hangup',
11337
-                    {
11338
-                        xmlns: this.RAYO_XMLNS
11339
-                    });
11340 11447
 
11341
-                this.connection.sendIQ(
11342
-                    req,
11343
-                    function (result) {
11344
-                        logger.info('Hangup result ', result);
11345
-                        self.call_resource = null;
11346
-                    },
11347
-                    function (error) {
11348
-                        logger.info('Hangup error ', error);
11349
-                        self.call_resource = null;
11350
-                    }
11351
-                );
11448
+                    var req = $iq(
11449
+                        {
11450
+                            type: 'set',
11451
+                            to: self.call_resource
11452
+                        }
11453
+                    );
11454
+                    req.c('hangup',
11455
+                        {
11456
+                            xmlns: self.RAYO_XMLNS
11457
+                        });
11458
+
11459
+                    self.connection.sendIQ(
11460
+                        req,
11461
+                        function (result) {
11462
+                            logger.info('Hangup result ', result);
11463
+                            self.call_resource = null;
11464
+                            resolve();
11465
+                        },
11466
+                        function (error) {
11467
+                            logger.info('Hangup error ', error);
11468
+                            self.call_resource = null;
11469
+                            reject(new Error('Hangup error '));
11470
+                        }
11471
+                    );
11472
+                });
11352 11473
             }
11353 11474
         }
11354 11475
     );
@@ -22934,7 +23055,11 @@ var XMPPEvents = {
22934 23055
     /**
22935 23056
      * Indicates that recording state changed.
22936 23057
      */
22937
-    RECORDING_STATE_CHANGED: "xmpp.recordingStateChanged"
23058
+    RECORDING_STATE_CHANGED: "xmpp.recordingStateChanged",
23059
+    /**
23060
+     * Indicates that phone number changed.
23061
+     */
23062
+    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
22938 23063
 };
22939 23064
 module.exports = XMPPEvents;
22940 23065
 

+ 45
- 1
modules/xmpp/ChatRoom.js Переглянути файл

@@ -80,6 +80,8 @@ function ChatRoom(connection, jid, password, XMPP, options) {
80 80
     this.session = null;
81 81
     var self = this;
82 82
     this.lastPresences = {};
83
+    this.phoneNumber = null;
84
+    this.phonePin = null;
83 85
 }
84 86
 
85 87
 ChatRoom.prototype.initPresenceMap = function () {
@@ -197,6 +199,7 @@ ChatRoom.prototype.createNonAnonymousRoom = function () {
197 199
 };
198 200
 
199 201
 ChatRoom.prototype.onPresence = function (pres) {
202
+    console.log(pres);
200 203
     var from = pres.getAttribute('from');
201 204
     // Parse roles.
202 205
     var member = {};
@@ -250,6 +253,16 @@ ChatRoom.prototype.onPresence = function (pres) {
250 253
                 break;
251 254
             case "jibri-recording-status":
252 255
                 var jibri = node;
256
+                break;
257
+            case "call-control":
258
+                console.log(pres);
259
+                var att = node.attributes;
260
+                if(!att)
261
+                    break;
262
+                this.phoneNumber = att.phone || null;
263
+                this.phonePin = att.pin || null;
264
+                this.eventEmitter.emit(XMPPEvents.PHONE_NUMBER_CHANGED);
265
+                break;
253 266
             default :
254 267
                 this.processNode(node, from);
255 268
         }
@@ -690,11 +703,42 @@ ChatRoom.prototype.getRecordingURL = function () {
690 703
  * @param token token for authentication
691 704
  */
692 705
 ChatRoom.prototype.toggleRecording = function (token) {
693
-    if(this.recording/** && this.isModerator()**/)
706
+    if(this.recording)
694 707
         return this.recording.toggleRecording(token);
695 708
 
696 709
     return new Promise(function(resolve, reject){
697 710
         reject(new Error("The conference is not created yet!"))});
698 711
 }
699 712
 
713
+/**
714
+ * Dials a number.
715
+ * @param number the number
716
+ */
717
+ChatRoom.prototype.dial = function (number) {
718
+    return this.connection.rayo.dial(number, "fromnumber",
719
+        Strophe.getNodeFromJid(this.myroomjid), this.password,
720
+        this.focusMucJid);
721
+}
722
+
723
+/**
724
+ * Hangup an existing call
725
+ */
726
+ChatRoom.prototype.hangup = function () {
727
+    return this.connection.rayo.hangup();
728
+}
729
+
730
+/**
731
+ * Returns the phone number for joining the conference.
732
+ */
733
+ChatRoom.prototype.getPhoneNumber = function () {
734
+    return this.phoneNumber;
735
+}
736
+
737
+/**
738
+ * Returns the pin for joining the conference with phone.
739
+ */
740
+ChatRoom.prototype.getPhonePin = function () {
741
+    return this.phonePin;
742
+}
743
+
700 744
 module.exports = ChatRoom;

+ 11
- 4
modules/xmpp/recording.js Переглянути файл

@@ -1,6 +1,7 @@
1 1
 /* global $, $iq, config, connection, focusMucJid, messageHandler,
2 2
    Toolbar, Util, Promise */
3 3
 var XMPPEvents = require("../../service/XMPP/XMPPEvents");
4
+var logger = require("jitsi-meet-logger").getLogger(__filename);
4 5
 
5 6
 function Recording(ee, connection, focusMucJid) {
6 7
     this.eventEmitter = ee;
@@ -40,7 +41,7 @@ Recording.prototype.setRecording = function (state, streamId, callback,
40 41
             streamid: streamId
41 42
         }).up();
42 43
 
43
-    console.log('Set jibri recording: '+state, iq);
44
+    logger.log('Set jibri recording: '+state, iq);
44 45
 
45 46
     this.connection.sendIQ(
46 47
         iq,
@@ -49,7 +50,7 @@ Recording.prototype.setRecording = function (state, streamId, callback,
49 50
             $(result).find('jibri').attr('url'));
50 51
         },
51 52
         function (error) {
52
-            console.log('Failed to start recording, error: ', error);
53
+            logger.log('Failed to start recording, error: ', error);
53 54
             errCallback(error);
54 55
         });
55 56
 };
@@ -58,8 +59,14 @@ Recording.prototype.toggleRecording = function (token) {
58 59
     var self = this;
59 60
     return new Promise(function(resolve, reject) {
60 61
         if (!token) {
61
-            console.error("No token passed!");
62 62
             reject(new Error("No token passed!"));
63
+            logger.error("No token passed!");
64
+            return;
65
+        }
66
+        if(self.state === "on") {
67
+            reject(new Error("Recording is already started!"));
68
+            logger.error("Recording is already started!");
69
+            return;
63 70
         }
64 71
 
65 72
         var oldState = self.state;
@@ -68,7 +75,7 @@ Recording.prototype.toggleRecording = function (token) {
68 75
         self.setRecording(newState,
69 76
             token,
70 77
             function (state, url) {
71
-                console.log("New recording state: ", state);
78
+                logger.log("New recording state: ", state);
72 79
                 if (state && state !== oldState) {
73 80
                     self.state = state;
74 81
                     self.url = url;

+ 82
- 63
modules/xmpp/strophe.rayo.js Переглянути файл

@@ -13,85 +13,104 @@ module.exports = function() {
13 13
                 }
14 14
 
15 15
                 this.connection.addHandler(
16
-                    this.onRayo.bind(this),
17
-                    this.RAYO_XMLNS, 'iq', 'set', null, null);
16
+                    this.onRayo.bind(this), this.RAYO_XMLNS, 'iq', 'set',
17
+                    null, null);
18 18
             },
19 19
             onRayo: function (iq) {
20 20
                 logger.info("Rayo IQ", iq);
21 21
             },
22
-            dial: function (to, from, roomName, roomPass) {
22
+            dial: function (to, from, roomName, roomPass, focusMucJid) {
23 23
                 var self = this;
24
-                var req = $iq(
25
-                    {
26
-                        type: 'set',
27
-                        to: this.connection.emuc.focusMucJid
24
+                return new Promise(function (resolve, reject) {
25
+                    if(self.call_resource) {
26
+                        reject(new Error("There is already started call!"));
27
+                        return;
28 28
                     }
29
-                );
30
-                req.c('dial',
31
-                    {
32
-                        xmlns: this.RAYO_XMLNS,
33
-                        to: to,
34
-                        from: from
35
-                    });
36
-                req.c('header',
37
-                    {
38
-                        name: 'JvbRoomName',
39
-                        value: roomName
40
-                    }).up();
41
-
42
-                if (roomPass !== null && roomPass.length) {
43
-
29
+                    if(!focusMucJid) {
30
+                        reject(new Error("Internal error!"));
31
+                        return;
32
+                    }
33
+                    var req = $iq(
34
+                        {
35
+                            type: 'set',
36
+                            to: focusMucJid
37
+                        }
38
+                    );
39
+                    req.c('dial',
40
+                        {
41
+                            xmlns: self.RAYO_XMLNS,
42
+                            to: to,
43
+                            from: from
44
+                        });
44 45
                     req.c('header',
45 46
                         {
46
-                            name: 'JvbRoomPassword',
47
-                            value: roomPass
47
+                            name: 'JvbRoomName',
48
+                            value: roomName
48 49
                         }).up();
49
-                }
50 50
 
51
-                this.connection.sendIQ(
52
-                    req,
53
-                    function (result) {
54
-                        logger.info('Dial result ', result);
51
+                    if (roomPass !== null && roomPass.length) {
55 52
 
56
-                        var resource = $(result).find('ref').attr('uri');
57
-                        this.call_resource = resource.substr('xmpp:'.length);
58
-                        logger.info(
59
-                            "Received call resource: " + this.call_resource);
60
-                    },
61
-                    function (error) {
62
-                        logger.info('Dial error ', error);
53
+                        req.c('header',
54
+                            {
55
+                                name: 'JvbRoomPassword',
56
+                                value: roomPass
57
+                            }).up();
63 58
                     }
64
-                );
65
-            },
66
-            hang_up: function () {
67
-                if (!this.call_resource) {
68
-                    logger.warn("No call in progress");
69
-                    return;
70
-                }
71 59
 
60
+                    self.connection.sendIQ(
61
+                        req,
62
+                        function (result) {
63
+                            logger.info('Dial result ', result);
64
+
65
+                            var resource = $(result).find('ref').attr('uri');
66
+                            self.call_resource =
67
+                                resource.substr('xmpp:'.length);
68
+                            logger.info(
69
+                                "Received call resource: " +
70
+                                self.call_resource);
71
+                            resolve();
72
+                        },
73
+                        function (error) {
74
+                            logger.info('Dial error ', error);
75
+                            reject(error);
76
+                        }
77
+                    );
78
+                });
79
+            },
80
+            hangup: function () {
72 81
                 var self = this;
73
-                var req = $iq(
74
-                    {
75
-                        type: 'set',
76
-                        to: this.call_resource
82
+                return new Promise(function (resolve, reject) {
83
+                    if (!self.call_resource) {
84
+                        reject(new Error("No call in progress"));
85
+                        logger.warn("No call in progress");
86
+                        return;
77 87
                     }
78
-                );
79
-                req.c('hangup',
80
-                    {
81
-                        xmlns: this.RAYO_XMLNS
82
-                    });
83 88
 
84
-                this.connection.sendIQ(
85
-                    req,
86
-                    function (result) {
87
-                        logger.info('Hangup result ', result);
88
-                        self.call_resource = null;
89
-                    },
90
-                    function (error) {
91
-                        logger.info('Hangup error ', error);
92
-                        self.call_resource = null;
93
-                    }
94
-                );
89
+                    var req = $iq(
90
+                        {
91
+                            type: 'set',
92
+                            to: self.call_resource
93
+                        }
94
+                    );
95
+                    req.c('hangup',
96
+                        {
97
+                            xmlns: self.RAYO_XMLNS
98
+                        });
99
+
100
+                    self.connection.sendIQ(
101
+                        req,
102
+                        function (result) {
103
+                            logger.info('Hangup result ', result);
104
+                            self.call_resource = null;
105
+                            resolve();
106
+                        },
107
+                        function (error) {
108
+                            logger.info('Hangup error ', error);
109
+                            self.call_resource = null;
110
+                            reject(new Error('Hangup error '));
111
+                        }
112
+                    );
113
+                });
95 114
             }
96 115
         }
97 116
     );

+ 5
- 1
service/xmpp/XMPPEvents.js Переглянути файл

@@ -101,6 +101,10 @@ var XMPPEvents = {
101 101
     /**
102 102
      * Indicates that recording state changed.
103 103
      */
104
-    RECORDING_STATE_CHANGED: "xmpp.recordingStateChanged"
104
+    RECORDING_STATE_CHANGED: "xmpp.recordingStateChanged",
105
+    /**
106
+     * Indicates that phone number changed.
107
+     */
108
+    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
105 109
 };
106 110
 module.exports = XMPPEvents;

Завантаження…
Відмінити
Зберегти