Bläddra i källkod

handle incoming messages

j8
isymchych 10 år sedan
förälder
incheckning
fc76aa5293
2 ändrade filer med 33 tillägg och 23 borttagningar
  1. 29
    19
      app.js
  2. 4
    4
      modules/UI/UI.js

+ 29
- 19
app.js Visa fil

@@ -1,4 +1,4 @@
1
-/* global $, JitsiMeetJS, config, Promise */
1
+/* global $, JitsiMeetJS, config, interfaceConfig */
2 2
 /* application specific logic */
3 3
 
4 4
 import "babel-polyfill";
@@ -90,15 +90,11 @@ function connect() {
90 90
         };
91 91
 
92 92
         var listenForFailure = function (event) {
93
-            handlers[event] = function () {
94
-                // convert arguments to array
95
-                var args = Array.prototype.slice.call(arguments);
96
-                args.unshift(event);
97
-                // [event, ...params]
98
-                console.error('CONNECTION FAILED:', args);
93
+            handlers[event] = function (...args) {
94
+                console.error(`CONNECTION FAILED: ${event}`, ...args);
99 95
 
100 96
                 unsubscribe();
101
-                reject(args);
97
+                reject([event, ...args]);
102 98
             };
103 99
         };
104 100
 
@@ -143,6 +139,17 @@ function initConference(connection, roomName) {
143 139
         }
144 140
     });
145 141
 
142
+    function getDisplayName(id) {
143
+        if (APP.conference.isLocalId(id)) {
144
+            return APP.settings.getDisplayName();
145
+        }
146
+
147
+        var user = users[id];
148
+        if (user && user.displayName) {
149
+            return user.displayName;
150
+        }
151
+    }
152
+
146 153
     room.on(ConferenceEvents.USER_JOINED, function (id) {
147 154
         users[id] = {
148 155
             displayName: undefined,
@@ -190,13 +197,21 @@ function initConference(connection, roomName) {
190 197
     });
191 198
 
192 199
 
193
-    room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
194
-        APP.UI.markVideoInterrupted(true);
195
-    });
196
-    room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
197
-        APP.UI.markVideoInterrupted(false);
198
-    });
200
+    if (!interfaceConfig.filmStripOnly) {
201
+        room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
202
+            APP.UI.markVideoInterrupted(true);
203
+        });
204
+        room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
205
+            APP.UI.markVideoInterrupted(false);
206
+        });
199 207
 
208
+        APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
209
+            room.sendTextMessage(message);
210
+        });
211
+        room.on(ConferenceEvents.MESSAGE_RECEIVED, function (userId, text) {
212
+            APP.UI.addMessage(userId, getDisplayName(userId), text, Date.now());
213
+        });
214
+    }
200 215
 
201 216
     APP.connectionquality.addListener(
202 217
         CQEvents.LOCALSTATS_UPDATED,
@@ -259,11 +274,6 @@ function initConference(connection, roomName) {
259 274
     });
260 275
 
261 276
 
262
-    APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
263
-        room.sendTextMessage(message);
264
-    });
265
-
266
-
267 277
     room.on(ConferenceErrors.PASSWORD_REQUIRED, function () {
268 278
         // FIXME handle
269 279
     });

+ 4
- 4
modules/UI/UI.js Visa fil

@@ -308,10 +308,6 @@ function chatSetSubject(text) {
308 308
     return Chat.chatSetSubject(text);
309 309
 }
310 310
 
311
-function updateChatConversation(from, displayName, message, stamp) {
312
-    return Chat.updateChatConversation(from, displayName, message, stamp);
313
-}
314
-
315 311
 function initEtherpad(name) {
316 312
     Etherpad.init(name);
317 313
 }
@@ -689,4 +685,8 @@ UI.markVideoInterrupted = function (interrupted) {
689 685
     }
690 686
 };
691 687
 
688
+UI.addMessage = function (from, displayName, message, stamp) {
689
+    Chat.updateChatConversation(from, displayName, message, stamp);
690
+};
691
+
692 692
 module.exports = UI;

Laddar…
Avbryt
Spara