handle incoming messages
This commit is contained in:
parent
ff6ec2ec6b
commit
fc76aa5293
48
app.js
48
app.js
|
@ -1,4 +1,4 @@
|
|||
/* global $, JitsiMeetJS, config, Promise */
|
||||
/* global $, JitsiMeetJS, config, interfaceConfig */
|
||||
/* application specific logic */
|
||||
|
||||
import "babel-polyfill";
|
||||
|
@ -90,15 +90,11 @@ function connect() {
|
|||
};
|
||||
|
||||
var listenForFailure = function (event) {
|
||||
handlers[event] = function () {
|
||||
// convert arguments to array
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift(event);
|
||||
// [event, ...params]
|
||||
console.error('CONNECTION FAILED:', args);
|
||||
handlers[event] = function (...args) {
|
||||
console.error(`CONNECTION FAILED: ${event}`, ...args);
|
||||
|
||||
unsubscribe();
|
||||
reject(args);
|
||||
reject([event, ...args]);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -143,6 +139,17 @@ function initConference(connection, roomName) {
|
|||
}
|
||||
});
|
||||
|
||||
function getDisplayName(id) {
|
||||
if (APP.conference.isLocalId(id)) {
|
||||
return APP.settings.getDisplayName();
|
||||
}
|
||||
|
||||
var user = users[id];
|
||||
if (user && user.displayName) {
|
||||
return user.displayName;
|
||||
}
|
||||
}
|
||||
|
||||
room.on(ConferenceEvents.USER_JOINED, function (id) {
|
||||
users[id] = {
|
||||
displayName: undefined,
|
||||
|
@ -190,13 +197,21 @@ function initConference(connection, roomName) {
|
|||
});
|
||||
|
||||
|
||||
room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
|
||||
APP.UI.markVideoInterrupted(true);
|
||||
});
|
||||
room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
|
||||
APP.UI.markVideoInterrupted(false);
|
||||
});
|
||||
if (!interfaceConfig.filmStripOnly) {
|
||||
room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
|
||||
APP.UI.markVideoInterrupted(true);
|
||||
});
|
||||
room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
|
||||
APP.UI.markVideoInterrupted(false);
|
||||
});
|
||||
|
||||
APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
|
||||
room.sendTextMessage(message);
|
||||
});
|
||||
room.on(ConferenceEvents.MESSAGE_RECEIVED, function (userId, text) {
|
||||
APP.UI.addMessage(userId, getDisplayName(userId), text, Date.now());
|
||||
});
|
||||
}
|
||||
|
||||
APP.connectionquality.addListener(
|
||||
CQEvents.LOCALSTATS_UPDATED,
|
||||
|
@ -259,11 +274,6 @@ function initConference(connection, roomName) {
|
|||
});
|
||||
|
||||
|
||||
APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
|
||||
room.sendTextMessage(message);
|
||||
});
|
||||
|
||||
|
||||
room.on(ConferenceErrors.PASSWORD_REQUIRED, function () {
|
||||
// FIXME handle
|
||||
});
|
||||
|
|
|
@ -308,10 +308,6 @@ function chatSetSubject(text) {
|
|||
return Chat.chatSetSubject(text);
|
||||
}
|
||||
|
||||
function updateChatConversation(from, displayName, message, stamp) {
|
||||
return Chat.updateChatConversation(from, displayName, message, stamp);
|
||||
}
|
||||
|
||||
function initEtherpad(name) {
|
||||
Etherpad.init(name);
|
||||
}
|
||||
|
@ -689,4 +685,8 @@ UI.markVideoInterrupted = function (interrupted) {
|
|||
}
|
||||
};
|
||||
|
||||
UI.addMessage = function (from, displayName, message, stamp) {
|
||||
Chat.updateChatConversation(from, displayName, message, stamp);
|
||||
};
|
||||
|
||||
module.exports = UI;
|
||||
|
|
Loading…
Reference in New Issue