|
@@ -10,7 +10,6 @@ var JitsiConnectionEvents = require("../../JitsiConnectionEvents");
|
10
|
10
|
var RTC = require("../RTC/RTC");
|
11
|
11
|
|
12
|
12
|
var authenticatedUser = false;
|
13
|
|
-var disconnectInProgress = false;
|
14
|
13
|
|
15
|
14
|
function createConnection(bosh) {
|
16
|
15
|
bosh = bosh || '/http-bind';
|
|
@@ -21,9 +20,9 @@ function createConnection(bosh) {
|
21
|
20
|
|
22
|
21
|
|
23
|
22
|
//!!!!!!!!!! FIXME: ...
|
24
|
|
-function initStrophePlugins()
|
|
23
|
+function initStrophePlugins(XMPP)
|
25
|
24
|
{
|
26
|
|
-// require("./strophe.emuc")(XMPP, eventEmitter);
|
|
25
|
+ require("./strophe.emuc")(XMPP);
|
27
|
26
|
// require("./strophe.jingle")(XMPP, eventEmitter);
|
28
|
27
|
// require("./strophe.moderate")(XMPP, eventEmitter);
|
29
|
28
|
require("./strophe.util")();
|
|
@@ -56,10 +55,11 @@ function XMPP(options) {
|
56
|
55
|
this.sessionTerminated = false;
|
57
|
56
|
this.eventEmitter = new EventEmitter();
|
58
|
57
|
this.connection = null;
|
|
58
|
+ this.disconnectInProgress = false;
|
59
|
59
|
|
60
|
60
|
this.forceMuted = false;
|
61
|
61
|
this.options = options;
|
62
|
|
- initStrophePlugins();
|
|
62
|
+ initStrophePlugins(this);
|
63
|
63
|
// registerListeners();
|
64
|
64
|
Moderator.init(this, this.eventEmitter);
|
65
|
65
|
this.connection = createConnection(options.bosh);
|
|
@@ -110,6 +110,7 @@ XMPP.prototype._connect = function (jid, password) {
|
110
|
110
|
self.connection.jingle.getStunAndTurnCredentials();
|
111
|
111
|
}
|
112
|
112
|
|
|
113
|
+
|
113
|
114
|
console.info("My Jabber ID: " + self.connection.jid);
|
114
|
115
|
|
115
|
116
|
if (password)
|
|
@@ -117,6 +118,7 @@ XMPP.prototype._connect = function (jid, password) {
|
117
|
118
|
if (self.connection && self.connection.connected &&
|
118
|
119
|
Strophe.getResourceFromJid(self.connection.jid)) {
|
119
|
120
|
// .connected is true while connecting?
|
|
121
|
+ self.connection.send($pres());
|
120
|
122
|
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
121
|
123
|
Strophe.getResourceFromJid(self.connection.jid));
|
122
|
124
|
}
|
|
@@ -130,6 +132,7 @@ XMPP.prototype._connect = function (jid, password) {
|
130
|
132
|
}
|
131
|
133
|
lastErrorMsg = msg;
|
132
|
134
|
} else if (status === Strophe.Status.DISCONNECTED) {
|
|
135
|
+ self.disconnectInProgress = false;
|
133
|
136
|
if (anonymousConnectionFailed) {
|
134
|
137
|
// prompt user for username and password
|
135
|
138
|
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_FAILED,
|
|
@@ -165,7 +168,7 @@ XMPP.prototype.connect = function (jid, password) {
|
165
|
168
|
};
|
166
|
169
|
|
167
|
170
|
XMPP.prototype.joinRoom = function(roomName, useNicks, nick) {
|
168
|
|
- var roomjid = roomName;
|
|
171
|
+ var roomjid = roomName + '@' + Strophe.getDomainFromJid(this.connection.jid);
|
169
|
172
|
|
170
|
173
|
if (useNicks) {
|
171
|
174
|
if (nick) {
|
|
@@ -181,20 +184,9 @@ XMPP.prototype.joinRoom = function(roomName, useNicks, nick) {
|
181
|
184
|
|
182
|
185
|
roomjid += '/' + tmpJid;
|
183
|
186
|
}
|
184
|
|
- this.connection.emuc.doJoin(roomjid);
|
|
187
|
+ return this.connection.emuc.doJoin(roomjid, null, this.eventEmitter);
|
185
|
188
|
};
|
186
|
189
|
|
187
|
|
-XMPP.prototype.myJid = function () {
|
188
|
|
- if(!this.connection)
|
189
|
|
- return null;
|
190
|
|
- return this.connection.emuc.myroomjid;
|
191
|
|
-}
|
192
|
|
-
|
193
|
|
-XMPP.prototype.myResource = function () {
|
194
|
|
- if(!this.connection || ! this.connection.emuc.myroomjid)
|
195
|
|
- return null;
|
196
|
|
- return Strophe.getResourceFromJid(this.connection.emuc.myroomjid);
|
197
|
|
-}
|
198
|
190
|
|
199
|
191
|
XMPP.prototype.disposeConference = function (onUnload) {
|
200
|
192
|
var handler = this.connection.jingle.activecall;
|
|
@@ -227,8 +219,8 @@ XMPP.prototype.removeListener = function (type, listener) {
|
227
|
219
|
this.eventEmitter.removeListener(type, listener);
|
228
|
220
|
};
|
229
|
221
|
|
230
|
|
-XMPP.prototype.leaveRoom = function () {
|
231
|
|
- this.connection.emuc.doLeave();
|
|
222
|
+XMPP.prototype.leaveRoom = function (jid) {
|
|
223
|
+ this.connection.emuc.doLeave(jid);
|
232
|
224
|
};
|
233
|
225
|
|
234
|
226
|
|
|
@@ -330,43 +322,6 @@ XMPP.prototype.sendAudioInfoPresence = function(mute, callback) {
|
330
|
322
|
return true;
|
331
|
323
|
};
|
332
|
324
|
|
333
|
|
-XMPP.prototype.addToPresence = function (name, value, dontSend) {
|
334
|
|
- switch (name) {
|
335
|
|
- case "displayName":
|
336
|
|
- this.connection.emuc.addDisplayNameToPresence(value);
|
337
|
|
- break;
|
338
|
|
- case "prezi":
|
339
|
|
- this.connection.emuc.addPreziToPresence(value, 0);
|
340
|
|
- break;
|
341
|
|
- case "preziSlide":
|
342
|
|
- this.connection.emuc.addCurrentSlideToPresence(value);
|
343
|
|
- break;
|
344
|
|
- case "connectionQuality":
|
345
|
|
- this.connection.emuc.addConnectionInfoToPresence(value);
|
346
|
|
- break;
|
347
|
|
- case "email":
|
348
|
|
- this.connection.emuc.addEmailToPresence(value);
|
349
|
|
- break;
|
350
|
|
- case "devices":
|
351
|
|
- this.connection.emuc.addDevicesToPresence(value);
|
352
|
|
- break;
|
353
|
|
- case "videoType":
|
354
|
|
- this.connection.emuc.addVideoTypeToPresence(value);
|
355
|
|
- break;
|
356
|
|
- case "startMuted":
|
357
|
|
- if(!Moderator.isModerator())
|
358
|
|
- return;
|
359
|
|
- this.connection.emuc.addStartMutedToPresence(value[0],
|
360
|
|
- value[1]);
|
361
|
|
- break;
|
362
|
|
- default :
|
363
|
|
- console.log("Unknown tag for presence: " + name);
|
364
|
|
- return;
|
365
|
|
- }
|
366
|
|
- if (!dontSend)
|
367
|
|
- this.connection.emuc.sendPresence();
|
368
|
|
-};
|
369
|
|
-
|
370
|
325
|
/**
|
371
|
326
|
* Sends 'data' as a log message to the focus. Returns true iff a message
|
372
|
327
|
* was sent.
|
|
@@ -408,17 +363,6 @@ XMPP.prototype.getXmppLog = function () {
|
408
|
363
|
return this.connection.logger ? this.connection.logger.log : null;
|
409
|
364
|
};
|
410
|
365
|
|
411
|
|
-XMPP.prototype.sendChatMessage = function (message, nickname) {
|
412
|
|
- this.connection.emuc.sendMessage(message, nickname);
|
413
|
|
-};
|
414
|
|
-
|
415
|
|
-XMPP.prototype.setSubject = function (topic) {
|
416
|
|
- this.connection.emuc.setSubject(topic);
|
417
|
|
-};
|
418
|
|
-
|
419
|
|
-XMPP.prototype.lockRoom = function (key, onSuccess, onError, onNotSupported) {
|
420
|
|
- this.connection.emuc.lockRoom(key, onSuccess, onError, onNotSupported);
|
421
|
|
-};
|
422
|
366
|
|
423
|
367
|
XMPP.prototype.dial = function (to, from, roomName,roomPass) {
|
424
|
368
|
this.connection.rayo.dial(to, from, roomName,roomPass);
|
|
@@ -436,25 +380,12 @@ XMPP.prototype.logout = function (callback) {
|
436
|
380
|
Moderator.logout(callback);
|
437
|
381
|
};
|
438
|
382
|
|
439
|
|
-XMPP.prototype.findJidFromResource = function (resource) {
|
440
|
|
- return this.connection.emuc.findJidFromResource(resource);
|
441
|
|
-};
|
442
|
|
-
|
443
|
|
-XMPP.prototype.getMembers = function () {
|
444
|
|
- return this.connection.emuc.members;
|
445
|
|
-};
|
446
|
|
-
|
447
|
383
|
XMPP.prototype.getJidFromSSRC = function (ssrc) {
|
448
|
384
|
if (!this.isConferenceInProgress())
|
449
|
385
|
return null;
|
450
|
386
|
return this.connection.jingle.activecall.getSsrcOwner(ssrc);
|
451
|
387
|
};
|
452
|
388
|
|
453
|
|
-// Returns true iff we have joined the MUC.
|
454
|
|
-XMPP.prototype.isMUCJoined = function () {
|
455
|
|
- return this.connection.emuc.joined;
|
456
|
|
-};
|
457
|
|
-
|
458
|
389
|
XMPP.prototype.getSessions = function () {
|
459
|
390
|
return this.connection.jingle.sessions;
|
460
|
391
|
};
|
|
@@ -466,13 +397,13 @@ XMPP.prototype.removeStream = function (stream) {
|
466
|
397
|
};
|
467
|
398
|
|
468
|
399
|
XMPP.prototype.disconnect = function (callback) {
|
469
|
|
- if (disconnectInProgress || !this.connection || !this.connection.connected)
|
|
400
|
+ if (this.disconnectInProgress || !this.connection || !this.connection.connected)
|
470
|
401
|
{
|
471
|
402
|
this.eventEmitter.emit(JitsiConnectionEvents.WRONG_STATE);
|
472
|
403
|
return;
|
473
|
404
|
}
|
474
|
405
|
|
475
|
|
- disconnectInProgress = true;
|
|
406
|
+ this.disconnectInProgress = true;
|
476
|
407
|
|
477
|
408
|
this.connection.disconnect();
|
478
|
409
|
};
|