Przeglądaj źródła

Changes redirect on unsupported browser to console.error.

dev1
hristoterezov 10 lat temu
rodzic
commit
be6a3be4cf
2 zmienionych plików z 47 dodań i 22 usunięć
  1. 45
    20
      lib-jitsi-meet.js
  2. 2
    2
      modules/RTC/RTCUtils.js

+ 45
- 20
lib-jitsi-meet.js Wyświetl plik

19
  */
19
  */
20
 
20
 
21
 function JitsiConference(options) {
21
 function JitsiConference(options) {
22
+    if(!options.name || options.name.toLowerCase() === options.name) {
23
+        console.error("Invalid conference name (no conference name passed or it"
24
+            + "contains invalid characters like capital letters)!");
25
+         return;
26
+    }
22
     this.options = options;
27
     this.options = options;
23
     this.connection = this.options.connection;
28
     this.connection = this.options.connection;
24
     this.xmpp = this.connection.xmpp;
29
     this.xmpp = this.connection.xmpp;
37
  * @param password {string} the password
42
  * @param password {string} the password
38
  */
43
  */
39
 JitsiConference.prototype.join = function (password) {
44
 JitsiConference.prototype.join = function (password) {
40
-    this.room.join(password);
45
+    if(this.room)
46
+        this.room.join(password);
41
 }
47
 }
42
 
48
 
43
 /**
49
 /**
44
  * Leaves the conference.
50
  * Leaves the conference.
45
  */
51
  */
46
 JitsiConference.prototype.leave = function () {
52
 JitsiConference.prototype.leave = function () {
47
-    this.xmpp.leaveRoom(this.room.roomjid);
53
+    if(this.xmpp)
54
+        this.xmpp.leaveRoom(this.room.roomjid);
48
     this.room = null;
55
     this.room = null;
49
 }
56
 }
50
 
57
 
56
  *     or a JitsiConferenceError if rejected.
63
  *     or a JitsiConferenceError if rejected.
57
  */
64
  */
58
 JitsiConference.prototype.createLocalTracks = function (options) {
65
 JitsiConference.prototype.createLocalTracks = function (options) {
59
-    return this.rtc.obtainAudioAndVideoPermissions(options || {});
66
+    if(this.rtc)
67
+        return this.rtc.obtainAudioAndVideoPermissions(options || {});
60
 }
68
 }
61
 
69
 
62
 /**
70
 /**
63
  * Returns the local tracks.
71
  * Returns the local tracks.
64
  */
72
  */
65
 JitsiConference.prototype.getLocalTracks = function () {
73
 JitsiConference.prototype.getLocalTracks = function () {
66
-    return this.rtc.localStreams;
74
+    if(this.rtc)
75
+        return this.rtc.localStreams;
67
 };
76
 };
68
 
77
 
69
 
78
 
76
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
85
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
77
  */
86
  */
78
 JitsiConference.prototype.on = function (eventId, handler) {
87
 JitsiConference.prototype.on = function (eventId, handler) {
79
-    this.eventEmitter.on(eventId, handler);
88
+    if(this.eventEmitter)
89
+        this.eventEmitter.on(eventId, handler);
80
 }
90
 }
81
 
91
 
82
 /**
92
 /**
87
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
97
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
88
  */
98
  */
89
 JitsiConference.prototype.off = function (eventId, handler) {
99
 JitsiConference.prototype.off = function (eventId, handler) {
90
-    this.eventEmitter.removeListener(eventId, listener);
100
+    if(this.eventEmitter)
101
+        this.eventEmitter.removeListener(eventId, listener);
91
 }
102
 }
92
 
103
 
93
 // Common aliases for event emitter
104
 // Common aliases for event emitter
100
  * @param handler {Function} handler for the command
111
  * @param handler {Function} handler for the command
101
  */
112
  */
102
  JitsiConference.prototype.addCommandListener = function (command, handler) {
113
  JitsiConference.prototype.addCommandListener = function (command, handler) {
103
-     this.room.addPresenceListener(command, handler);
114
+    if(this.room)
115
+        this.room.addPresenceListener(command, handler);
104
  }
116
  }
105
 
117
 
106
 /**
118
 /**
108
   * @param command {String}  the name of the command
120
   * @param command {String}  the name of the command
109
   */
121
   */
110
  JitsiConference.prototype.removeCommandListener = function (command) {
122
  JitsiConference.prototype.removeCommandListener = function (command) {
111
-    this.room.removePresenceListener(command);
123
+    if(this.room)
124
+        this.room.removePresenceListener(command);
112
  }
125
  }
113
 
126
 
114
 /**
127
 /**
116
  * @param message the text message.
129
  * @param message the text message.
117
  */
130
  */
118
 JitsiConference.prototype.sendTextMessage = function (message) {
131
 JitsiConference.prototype.sendTextMessage = function (message) {
119
-    this.room.sendMessage(message);
132
+    if(this.room)
133
+        this.room.sendMessage(message);
120
 }
134
 }
121
 
135
 
122
 /**
136
 /**
125
  * @param values Object with keys and values that will be send.
139
  * @param values Object with keys and values that will be send.
126
  **/
140
  **/
127
 JitsiConference.prototype.sendCommand = function (name, values) {
141
 JitsiConference.prototype.sendCommand = function (name, values) {
128
-    this.room.addToPresence(name, values);
129
-    this.room.sendPresence();
142
+    if(this.room) {
143
+        this.room.addToPresence(name, values);
144
+        this.room.sendPresence();
145
+    }
130
 }
146
 }
131
 
147
 
132
 /**
148
 /**
146
  * @param persistent if false the command will be sent only one time
162
  * @param persistent if false the command will be sent only one time
147
  **/
163
  **/
148
 JitsiConference.prototype.removeCommand = function (name) {
164
 JitsiConference.prototype.removeCommand = function (name) {
149
-    this.room.removeFromPresence(name);
165
+    if(this.room)
166
+        this.room.removeFromPresence(name);
150
 }
167
 }
151
 
168
 
152
 /**
169
 /**
154
  * @param name the display name to set
171
  * @param name the display name to set
155
  */
172
  */
156
 JitsiConference.prototype.setDisplayName = function(name) {
173
 JitsiConference.prototype.setDisplayName = function(name) {
157
-    this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
158
-    this.room.sendPresence();
174
+    if(this.room){
175
+        this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
176
+        this.room.sendPresence();
177
+    }
159
 }
178
 }
160
 
179
 
161
 /**
180
 /**
163
  * @param id the identifier of the participant
182
  * @param id the identifier of the participant
164
  */
183
  */
165
 JitsiConference.prototype.selectParticipant = function(participantId) {
184
 JitsiConference.prototype.selectParticipant = function(participantId) {
166
-    this.rtc.selectedEndpoint(participantId);
185
+    if (this.rtc) {
186
+        this.rtc.selectedEndpoint(participantId);
187
+    }
167
 }
188
 }
168
 
189
 
169
 /**
190
 /**
171
  * @param id the identifier of the participant
192
  * @param id the identifier of the participant
172
  */
193
  */
173
 JitsiConference.prototype.pinParticipant = function(participantId) {
194
 JitsiConference.prototype.pinParticipant = function(participantId) {
174
-    this.rtc.pinEndpoint(participantId);
195
+    if(this.rtc)
196
+        this.rtc.pinEndpoint(participantId);
175
 }
197
 }
176
 
198
 
177
 /**
199
 /**
188
  * @param id the id of the participant.
210
  * @param id the id of the participant.
189
  */
211
  */
190
 JitsiConference.prototype.getParticipantById = function(id) {
212
 JitsiConference.prototype.getParticipantById = function(id) {
191
-    return this.participants[id];
213
+    if(this.participants)
214
+        return this.participants[id];
215
+    return null;
192
 }
216
 }
193
 
217
 
194
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
218
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
195
-    this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, Strophe.getResourceFromJid(jid));
219
+    if(this.eventEmitter)
220
+        this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, Strophe.getResourceFromJid(jid));
196
 //    this.participants[jid] = new JitsiParticipant();
221
 //    this.participants[jid] = new JitsiParticipant();
197
 }
222
 }
198
 
223
 
2063
             });
2088
             });
2064
         } else {
2089
         } else {
2065
             try {
2090
             try {
2066
-                console.log('Browser does not appear to be WebRTC-capable');
2091
+                console.error('Browser does not appear to be WebRTC-capable');
2067
             } catch (e) {
2092
             } catch (e) {
2068
             }
2093
             }
2069
-            window.location.href = 'unsupported_browser.html';
2094
+            return;
2070
         }
2095
         }
2071
 
2096
 
2072
     },
2097
     },

+ 2
- 2
modules/RTC/RTCUtils.js Wyświetl plik

288
             });
288
             });
289
         } else {
289
         } else {
290
             try {
290
             try {
291
-                console.log('Browser does not appear to be WebRTC-capable');
291
+                console.error('Browser does not appear to be WebRTC-capable');
292
             } catch (e) {
292
             } catch (e) {
293
             }
293
             }
294
-            window.location.href = 'unsupported_browser.html';
294
+            return;
295
         }
295
         }
296
 
296
 
297
     },
297
     },

Ładowanie…
Anuluj
Zapisz