Ver código fonte

Changes redirect on unsupported browser to console.error.

dev1
hristoterezov 10 anos atrás
pai
commit
be6a3be4cf
2 arquivos alterados com 47 adições e 22 exclusões
  1. 45
    20
      lib-jitsi-meet.js
  2. 2
    2
      modules/RTC/RTCUtils.js

+ 45
- 20
lib-jitsi-meet.js Ver arquivo

@@ -19,6 +19,11 @@ var Statistics = require("./modules/statistics/statistics");
19 19
  */
20 20
 
21 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 27
     this.options = options;
23 28
     this.connection = this.options.connection;
24 29
     this.xmpp = this.connection.xmpp;
@@ -37,14 +42,16 @@ function JitsiConference(options) {
37 42
  * @param password {string} the password
38 43
  */
39 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 50
  * Leaves the conference.
45 51
  */
46 52
 JitsiConference.prototype.leave = function () {
47
-    this.xmpp.leaveRoom(this.room.roomjid);
53
+    if(this.xmpp)
54
+        this.xmpp.leaveRoom(this.room.roomjid);
48 55
     this.room = null;
49 56
 }
50 57
 
@@ -56,14 +63,16 @@ JitsiConference.prototype.leave = function () {
56 63
  *     or a JitsiConferenceError if rejected.
57 64
  */
58 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 71
  * Returns the local tracks.
64 72
  */
65 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,7 +85,8 @@ JitsiConference.prototype.getLocalTracks = function () {
76 85
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
77 86
  */
78 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,7 +97,8 @@ JitsiConference.prototype.on = function (eventId, handler) {
87 97
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
88 98
  */
89 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 104
 // Common aliases for event emitter
@@ -100,7 +111,8 @@ JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off
100 111
  * @param handler {Function} handler for the command
101 112
  */
102 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,7 +120,8 @@ JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off
108 120
   * @param command {String}  the name of the command
109 121
   */
110 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,7 +129,8 @@ JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off
116 129
  * @param message the text message.
117 130
  */
118 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,8 +139,10 @@ JitsiConference.prototype.sendTextMessage = function (message) {
125 139
  * @param values Object with keys and values that will be send.
126 140
  **/
127 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,7 +162,8 @@ JitsiConference.prototype.sendCommandOnce = function (name, values) {
146 162
  * @param persistent if false the command will be sent only one time
147 163
  **/
148 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,8 +171,10 @@ JitsiConference.prototype.removeCommand = function (name) {
154 171
  * @param name the display name to set
155 172
  */
156 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,7 +182,9 @@ JitsiConference.prototype.setDisplayName = function(name) {
163 182
  * @param id the identifier of the participant
164 183
  */
165 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,7 +192,8 @@ JitsiConference.prototype.selectParticipant = function(participantId) {
171 192
  * @param id the identifier of the participant
172 193
  */
173 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,11 +210,14 @@ JitsiConference.prototype.getParticipants = function() {
188 210
  * @param id the id of the participant.
189 211
  */
190 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 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 221
 //    this.participants[jid] = new JitsiParticipant();
197 222
 }
198 223
 
@@ -2063,10 +2088,10 @@ var RTCUtils = {
2063 2088
             });
2064 2089
         } else {
2065 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 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 Ver arquivo

@@ -288,10 +288,10 @@ var RTCUtils = {
288 288
             });
289 289
         } else {
290 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 292
             } catch (e) {
293 293
             }
294
-            window.location.href = 'unsupported_browser.html';
294
+            return;
295 295
         }
296 296
 
297 297
     },

Carregando…
Cancelar
Salvar