Browse Source

Fixes using options from correct locations, per conference or per connection.

master
damencho 9 years ago
parent
commit
7cc832e9ee
2 changed files with 34 additions and 32 deletions
  1. 1
    1
      modules/xmpp/ChatRoom.js
  2. 33
    31
      modules/xmpp/moderator.js

+ 1
- 1
modules/xmpp/ChatRoom.js View File

76
     this.bridgeIsDown = false;
76
     this.bridgeIsDown = false;
77
     this.options = options || {};
77
     this.options = options || {};
78
     this.moderator = new Moderator(this.roomjid, this.xmpp, this.eventEmitter,
78
     this.moderator = new Moderator(this.roomjid, this.xmpp, this.eventEmitter,
79
-        settings);
79
+        settings, {connection: this.xmpp.options, conference: this.options});
80
     this.initPresenceMap();
80
     this.initPresenceMap();
81
     this.session = null;
81
     this.session = null;
82
     var self = this;
82
     var self = this;

+ 33
- 31
modules/xmpp/moderator.js View File

21
     };
21
     };
22
 }
22
 }
23
 
23
 
24
-function Moderator(roomName, xmpp, emitter, settings) {
24
+function Moderator(roomName, xmpp, emitter, settings, options) {
25
     this.roomName = roomName;
25
     this.roomName = roomName;
26
     this.xmppService = xmpp;
26
     this.xmppService = xmpp;
27
     this.getNextTimeout = createExpBackoffTimer(1000);
27
     this.getNextTimeout = createExpBackoffTimer(1000);
29
     // External authentication stuff
29
     // External authentication stuff
30
     this.externalAuthEnabled = false;
30
     this.externalAuthEnabled = false;
31
     this.settings = settings;
31
     this.settings = settings;
32
+    this.options = options;
33
+
32
     // Sip gateway can be enabled by configuring Jigasi host in config.js or
34
     // Sip gateway can be enabled by configuring Jigasi host in config.js or
33
     // it will be enabled automatically if focus detects the component through
35
     // it will be enabled automatically if focus detects the component through
34
     // service discovery.
36
     // service discovery.
35
-    this.sipGatewayEnabled = this.xmppService.options.hosts &&
36
-        this.xmppService.options.hosts.call_control !== undefined;
37
+    this.sipGatewayEnabled = this.options.connection.hosts &&
38
+        this.options.connection.hosts.call_control !== undefined;
37
 
39
 
38
     this.eventEmitter = emitter;
40
     this.eventEmitter = emitter;
39
 
41
 
94
 
96
 
95
 Moderator.prototype.getFocusComponent =  function () {
97
 Moderator.prototype.getFocusComponent =  function () {
96
     // Get focus component address
98
     // Get focus component address
97
-    var focusComponent = this.xmppService.options.hosts.focus;
99
+    var focusComponent = this.options.connection.hosts.focus;
98
     // If not specified use default:  'focus.domain'
100
     // If not specified use default:  'focus.domain'
99
     if (!focusComponent) {
101
     if (!focusComponent) {
100
-        focusComponent = 'focus.' + this.xmppService.options.hosts.domain;
102
+        focusComponent = 'focus.' + this.options.connection.hosts.domain;
101
     }
103
     }
102
     return focusComponent;
104
     return focusComponent;
103
 };
105
 };
109
     // Session Id used for authentication
111
     // Session Id used for authentication
110
     var sessionId = this.settings.getSessionId();
112
     var sessionId = this.settings.getSessionId();
111
     var machineUID = this.settings.getUserId();
113
     var machineUID = this.settings.getUserId();
112
-    var options = this.xmppService.options;
113
 
114
 
114
     logger.info(
115
     logger.info(
115
             "Session ID: " + sessionId + " machine UID: " + machineUID);
116
             "Session ID: " + sessionId + " machine UID: " + machineUID);
123
     if (sessionId) {
124
     if (sessionId) {
124
         elem.attrs({ 'session-id': sessionId});
125
         elem.attrs({ 'session-id': sessionId});
125
     }
126
     }
126
-    if (options.hosts !== undefined && options.hosts.bridge !== undefined) {
127
+    if (this.options.connection.hosts !== undefined
128
+        && this.options.connection.hosts.bridge !== undefined) {
127
         elem.c(
129
         elem.c(
128
             'property', {
130
             'property', {
129
                 name: 'bridge',
131
                 name: 'bridge',
130
-                value: options.hosts.bridge
132
+                value: this.options.connection.hosts.bridge
131
             }).up();
133
             }).up();
132
     }
134
     }
133
-    if (options.enforcedBridge !== undefined) {
135
+    if (this.options.connection.enforcedBridge !== undefined) {
134
         elem.c(
136
         elem.c(
135
             'property', {
137
             'property', {
136
                 name: 'enforcedBridge',
138
                 name: 'enforcedBridge',
137
-                value: options.enforcedBridge
139
+                value: this.options.connection.enforcedBridge
138
             }).up();
140
             }).up();
139
     }
141
     }
140
     // Tell the focus we have Jigasi configured
142
     // Tell the focus we have Jigasi configured
141
-    if (options.hosts !== undefined &&
142
-        options.hosts.call_control !== undefined) {
143
+    if (this.options.connection.hosts !== undefined &&
144
+        this.options.connection.hosts.call_control !== undefined) {
143
         elem.c(
145
         elem.c(
144
             'property', {
146
             'property', {
145
                 name: 'call_control',
147
                 name: 'call_control',
146
-                value: options.hosts.call_control
148
+                value: this.options.connection.hosts.call_control
147
             }).up();
149
             }).up();
148
     }
150
     }
149
-    if (options.channelLastN !== undefined) {
151
+    if (this.options.conference.channelLastN !== undefined) {
150
         elem.c(
152
         elem.c(
151
             'property', {
153
             'property', {
152
                 name: 'channelLastN',
154
                 name: 'channelLastN',
153
-                value: options.channelLastN
155
+                value: this.options.conference.channelLastN
154
             }).up();
156
             }).up();
155
     }
157
     }
156
-    if (options.adaptiveLastN !== undefined) {
158
+    if (this.options.conference.adaptiveLastN !== undefined) {
157
         elem.c(
159
         elem.c(
158
             'property', {
160
             'property', {
159
                 name: 'adaptiveLastN',
161
                 name: 'adaptiveLastN',
160
-                value: options.adaptiveLastN
162
+                value: this.options.conference.adaptiveLastN
161
             }).up();
163
             }).up();
162
     }
164
     }
163
-    if (options.disableAdaptiveSimulcast !== undefined ||
164
-        options.disableSimulcast) {
165
+    if (this.options.conference.disableAdaptiveSimulcast !== undefined ||
166
+        this.options.conference.disableSimulcast) {
165
         // disableSimulcast implies disableAdaptiveSimulcast.
167
         // disableSimulcast implies disableAdaptiveSimulcast.
166
-        var value = options.disableSimulcast ? true :
167
-            options.disableAdaptiveSimulcast;
168
+        var value = this.options.conference.disableSimulcast ? true :
169
+            this.options.conference.disableAdaptiveSimulcast;
168
         elem.c(
170
         elem.c(
169
             'property', {
171
             'property', {
170
                 name: 'disableAdaptiveSimulcast',
172
                 name: 'disableAdaptiveSimulcast',
172
             }).up();
174
             }).up();
173
     }
175
     }
174
     // TODO: re-enable once rtx is stable
176
     // TODO: re-enable once rtx is stable
175
-    //if (options.disableRtx !== undefined) {
177
+    //if (this.options.conference.disableRtx !== undefined) {
176
         elem.c(
178
         elem.c(
177
             'property', {
179
             'property', {
178
                 name: 'disableRtx',
180
                 name: 'disableRtx',
179
-                //value: options.disableRtx
181
+                //value: this.options.conference.disableRtx
180
                 value: true
182
                 value: true
181
             }).up();
183
             }).up();
182
     //}
184
     //}
183
-    if (options.openSctp !== undefined) {
185
+    if (this.options.conference.openSctp !== undefined) {
184
         elem.c(
186
         elem.c(
185
             'property', {
187
             'property', {
186
                 name: 'openSctp',
188
                 name: 'openSctp',
187
-                value: options.openSctp
189
+                value: this.options.conference.openSctp
188
             }).up();
190
             }).up();
189
     }
191
     }
190
-    if (options.startAudioMuted !== undefined)
192
+    if (this.options.conference.startAudioMuted !== undefined)
191
     {
193
     {
192
         elem.c(
194
         elem.c(
193
             'property', {
195
             'property', {
194
                 name: 'startAudioMuted',
196
                 name: 'startAudioMuted',
195
-                value: options.startAudioMuted
197
+                value: this.options.conference.startAudioMuted
196
             }).up();
198
             }).up();
197
     }
199
     }
198
-    if (options.startVideoMuted !== undefined)
200
+    if (this.options.conference.startVideoMuted !== undefined)
199
     {
201
     {
200
         elem.c(
202
         elem.c(
201
             'property', {
203
             'property', {
202
                 name: 'startVideoMuted',
204
                 name: 'startVideoMuted',
203
-                value: options.startVideoMuted
205
+                value: this.options.conference.startVideoMuted
204
             }).up();
206
             }).up();
205
     }
207
     }
206
 
208
 
272
  */
274
  */
273
 Moderator.prototype.allocateConferenceFocus =  function (callback) {
275
 Moderator.prototype.allocateConferenceFocus =  function (callback) {
274
     // Try to use focus user JID from the config
276
     // Try to use focus user JID from the config
275
-    this.setFocusUserJid(this.xmppService.options.focusUserJid);
277
+    this.setFocusUserJid(this.options.connection.focusUserJid);
276
     // Send create conference IQ
278
     // Send create conference IQ
277
     var self = this;
279
     var self = this;
278
     this.connection.sendIQ(
280
     this.connection.sendIQ(
331
     if ($(error).find('>error>not-authorized').length) {
333
     if ($(error).find('>error>not-authorized').length) {
332
         logger.warn("Unauthorized to start the conference", error);
334
         logger.warn("Unauthorized to start the conference", error);
333
         var toDomain = Strophe.getDomainFromJid(error.getAttribute('to'));
335
         var toDomain = Strophe.getDomainFromJid(error.getAttribute('to'));
334
-        if (toDomain !== self.xmppService.options.hosts.anonymousdomain) {
336
+        if (toDomain !== self.options.connection.hosts.anonymousdomain) {
335
             //FIXME "is external" should come either from the focus or config.js
337
             //FIXME "is external" should come either from the focus or config.js
336
             self.externalAuthEnabled = true;
338
             self.externalAuthEnabled = true;
337
         }
339
         }

Loading…
Cancel
Save