|
@@ -18,21 +18,10 @@ function JitsiConnection(appID, token, options) {
|
18
|
18
|
this.options = options;
|
19
|
19
|
this.xmpp = new XMPP(options, token);
|
20
|
20
|
this.conferences = {};
|
21
|
|
- this.retryOnFail = 0;
|
22
|
|
- this.addEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
23
|
|
- function () {
|
24
|
|
- this.retryOnFail = 3;
|
25
|
|
- }.bind(this));
|
26
|
21
|
|
27
|
22
|
this.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED,
|
28
|
23
|
function (errType, msg) {
|
29
|
24
|
Statistics.analytics.sendEvent('connection.failed.' + errType);
|
30
|
|
- if(errType === JitsiConnectionErrors.OTHER_ERROR &&
|
31
|
|
- (msg === "item-not-found" || msg === "host-unknown")) {
|
32
|
|
- var reason = "connectionError." + msg.replace(/-/g,"_");
|
33
|
|
- // FIXME: don't report the error if we are going to reload
|
34
|
|
- this._reload(reason);
|
35
|
|
- }
|
36
|
25
|
}.bind(this));
|
37
|
26
|
|
38
|
27
|
this.addEventListener(JitsiConnectionEvents.CONNECTION_DISCONNECTED,
|
|
@@ -69,43 +58,6 @@ JitsiConnection.prototype.attach = function (options) {
|
69
|
58
|
this.xmpp.attach(options);
|
70
|
59
|
}
|
71
|
60
|
|
72
|
|
-/**
|
73
|
|
- * Reloads the JitsiConnection instance and all related conferences
|
74
|
|
- * @param reason {String} the reason for the reload.
|
75
|
|
- */
|
76
|
|
-JitsiConnection.prototype._reload = function (reason) {
|
77
|
|
- if(this.retryOnFail === 0)
|
78
|
|
- return false;
|
79
|
|
- Statistics.sendReloadEvent(reason);
|
80
|
|
- this.retryOnFail--;
|
81
|
|
- var states = {};
|
82
|
|
- for(var name in this.conferences) {
|
83
|
|
- states[name] = this.conferences[name].room.exportState();
|
84
|
|
- this.conferences[name].leave(true);
|
85
|
|
- }
|
86
|
|
- this.connectionEstablishedHandler =
|
87
|
|
- this._reloadConferences.bind(this, states);
|
88
|
|
- this.addEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
89
|
|
- this.connectionEstablishedHandler);
|
90
|
|
- this.xmpp.reload();
|
91
|
|
- return true;
|
92
|
|
-}
|
93
|
|
-
|
94
|
|
-/**
|
95
|
|
- * Reloads all conferences related to this JitsiConnection instance
|
96
|
|
- * @param states {object} the exported states per conference
|
97
|
|
- */
|
98
|
|
-JitsiConnection.prototype._reloadConferences = function (states) {
|
99
|
|
- this.removeEventListener(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
|
100
|
|
- this.connectionEstablishedHandler);
|
101
|
|
- this.connectionEstablishedHandler = null;
|
102
|
|
- states = states || {};
|
103
|
|
- for(var name in this.conferences) {
|
104
|
|
- this.conferences[name]._init({roomState: states[name]});
|
105
|
|
- this.conferences[name].join();
|
106
|
|
- }
|
107
|
|
-}
|
108
|
|
-
|
109
|
61
|
/**
|
110
|
62
|
* Disconnect the client from the server.
|
111
|
63
|
*/
|