Adds partial support for multiple chat rooms. Implements join and leave methods.

This commit is contained in:
hristoterezov 2015-08-26 20:37:17 -05:00
parent 89c7ff3a71
commit 455a6e10fe
7 changed files with 1268 additions and 846 deletions

View File

@ -1,4 +1,6 @@
var xmpp = require("./modules/xmpp/xmpp");
var room = null;
/**
* Creates a JitsiConference object with the given name and properties.
* Note: this constructor is not a part of the public API (objects should be
@ -10,21 +12,24 @@ var xmpp = require("./modules/xmpp/xmpp");
*/
function JitsiConference(options) {
this.options = options;
this.options = options;
this.connection = this.options.connection;
this.xmpp = this.connection.xmpp;
}
/**
* Joins the conference.
*/
JitsiConference.prototype.join = function () {
xmpp.joinRoom(this.options.name, null, null);
room = this.xmpp.joinRoom(this.options.name, null, null);
}
/**
* Leaves the conference.
*/
JitsiConference.prototype.leave = function () {
xmpp.l
this.xmpp.leaveRoom(room.roomjid);
room = null;
}
/**
@ -55,7 +60,7 @@ JitsiConference.prototype.getLocalTracks = function () {
* Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
*/
JitsiConference.prototype.on = function (eventId, handler) {
this.xmpp.addListener(eventId, handler);
}
/**
@ -66,7 +71,7 @@ JitsiConference.prototype.on = function (eventId, handler) {
* Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
*/
JitsiConference.prototype.off = function (eventId, handler) {
this.xmpp.removeListener(event, listener);
}
// Common aliases for event emitter
@ -95,7 +100,7 @@ JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off
* @param message the text message.
*/
JitsiConference.prototype.sendTextMessage = function (message) {
room.send
}
/**
@ -117,7 +122,7 @@ JitsiConference.prototype.sendCommand = function (name, values, persistent) {
* @param name the display name to set
*/
JitsiConference.prototype.setDisplayName = function(name) {
room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
}
/**

View File

@ -1,6 +1,11 @@
var JitsiConference = require("./JitsiConference");
var XMPP = require("./modules/xmpp/xmpp");
function wrapper()
{
var jitsiconnectioninstance = new JitsiConnection();
this.a = jitsiconnectioninstance.a();
}
/**
* Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
* JitsiConference interface.
@ -57,7 +62,7 @@ JitsiConnection.prototype.initJitsiConference = function (name, options) {
* @param event {JitsiConnectionEvents} the connection event.
* @param listener {Function} the function that will receive the event
*/
JitsiConnection.prototype.addListener = function (event, listener) {
JitsiConnection.prototype.addEventListener = function (event, listener) {
this.xmpp.addListener(event, listener);
}
@ -66,7 +71,7 @@ JitsiConnection.prototype.addListener = function (event, listener) {
* @param event {JitsiConnectionEvents} the connection event.
* @param listener {Function} the function that will receive the event
*/
JitsiConnection.prototype.removeListener = function (event, listener) {
JitsiConnection.prototype.removeEventListener = function (event, listener) {
this.xmpp.removeListener(event, listener);
}

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ function startSendingStats() {
* Sends statistics to other participants
*/
function sendStats() {
APP.xmpp.addToPresence("connectionQuality", convertToMUCStats(stats));
APP.xmpp.addToPresence("stats", convertToMUCStats(stats));
}
/**
@ -45,11 +45,32 @@ function sendStats() {
*/
function convertToMUCStats(stats) {
return {
"bitrate_download": stats.bitrate.download,
"bitrate_upload": stats.bitrate.upload,
"packetLoss_total": stats.packetLoss.total,
"packetLoss_download": stats.packetLoss.download,
"packetLoss_upload": stats.packetLoss.upload
tagName: "stats",
attributes: {
xmlns: 'http://jitsi.org/jitmeet/stats'
},
children: [
{
tagName: "stat",
attributes: {name: "bitrate_download", value: stats.bitrate.download}
},
{
tagName: "stat",
attributes: {name: "bitrate_upload", value: stats.bitrate.upload}
},
{
tagName: "stat",
attributes: {name: "packetLoss_total", value: stats.packetLoss.total}
},
{
tagName: "stat",
attributes: {name: "packetLoss_download", value: stats.packetLoss.download}
},
{
tagName: "stat",
attributes: {name: "packetLoss_upload", value: stats.packetLoss.upload}
}
]
};
}

View File

@ -1,9 +1,3 @@
var email = '';
var displayName = '';
var userId;
var language = null;
function supportsLocalStorage() {
try {
return 'localStorage' in window && window.localStorage !== null;
@ -21,43 +15,58 @@ function generateUniqueId() {
return _p8() + _p8() + _p8() + _p8();
}
if (supportsLocalStorage()) {
if (!window.localStorage.jitsiMeetId) {
window.localStorage.jitsiMeetId = generateUniqueId();
console.log("generated id", window.localStorage.jitsiMeetId);
function Settings(conferenceID) {
this.email = '';
this.displayName = '';
this.userId;
this.language = null;
this.confSettings = null;
if (supportsLocalStorage()) {
if(!window.localStorage.jitsiConferences)
window.localStorage.jitsiConferences = {}
if (!window.localStorage.jitsiConferences[conferenceID]) {
window.localStorage.jitsiConferences[conferenceID] = {}
}
this.confSettings = window.localStorage.jitsiConferences[conferenceID];
if(!this.confSettings.jitsiMeetId) {
this.confSettings.jitsiMeetId = generateUniqueId();
console.log("generated id",
this.confSettings.jitsiMeetId);
}
this.userId = this.confSettings.jitsiMeetId || '';
this.email = this.confSettings.email || '';
this.displayName = this.confSettings.displayname || '';
this.language = this.confSettings.language;
} else {
console.log("local storage is not supported");
this.userId = generateUniqueId();
}
userId = window.localStorage.jitsiMeetId || '';
email = window.localStorage.email || '';
displayName = window.localStorage.displayname || '';
language = window.localStorage.language;
} else {
console.log("local storage is not supported");
userId = generateUniqueId();
}
var Settings = {
setDisplayName: function (newDisplayName) {
displayName = newDisplayName;
window.localStorage.displayname = displayName;
return displayName;
},
setEmail: function (newEmail) {
email = newEmail;
window.localStorage.email = newEmail;
return email;
},
getSettings: function () {
return {
email: email,
displayName: displayName,
uid: userId,
language: language
};
},
setLanguage: function (lang) {
language = lang;
window.localStorage.language = lang;
}
};
Settings.prototype.setDisplayName = function (newDisplayName) {
this.displayName = newDisplayName;
if(this.confSettings != null)
this.confSettings.displayname = displayName;
return this.displayName;
},
Settings.prototype.setEmail = function (newEmail) {
this.email = newEmail;
if(this.confSettings != null)
this.confSettings.email = newEmail;
return this.email;
},
Settings.prototype.getSettings = function () {
return {
email: this.email,
displayName: this.displayName,
uid: this.userId,
language: this.language
};
},
Settings.prototype.setLanguage = function (lang) {
this.language = lang;
if(this.confSettings != null)
this.confSettings.language = lang;
}
module.exports = Settings;

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@ var JitsiConnectionEvents = require("../../JitsiConnectionEvents");
var RTC = require("../RTC/RTC");
var authenticatedUser = false;
var disconnectInProgress = false;
function createConnection(bosh) {
bosh = bosh || '/http-bind';
@ -21,9 +20,9 @@ function createConnection(bosh) {
//!!!!!!!!!! FIXME: ...
function initStrophePlugins()
function initStrophePlugins(XMPP)
{
// require("./strophe.emuc")(XMPP, eventEmitter);
require("./strophe.emuc")(XMPP);
// require("./strophe.jingle")(XMPP, eventEmitter);
// require("./strophe.moderate")(XMPP, eventEmitter);
require("./strophe.util")();
@ -56,10 +55,11 @@ function XMPP(options) {
this.sessionTerminated = false;
this.eventEmitter = new EventEmitter();
this.connection = null;
this.disconnectInProgress = false;
this.forceMuted = false;
this.options = options;
initStrophePlugins();
initStrophePlugins(this);
// registerListeners();
Moderator.init(this, this.eventEmitter);
this.connection = createConnection(options.bosh);
@ -110,6 +110,7 @@ XMPP.prototype._connect = function (jid, password) {
self.connection.jingle.getStunAndTurnCredentials();
}
console.info("My Jabber ID: " + self.connection.jid);
if (password)
@ -117,6 +118,7 @@ XMPP.prototype._connect = function (jid, password) {
if (self.connection && self.connection.connected &&
Strophe.getResourceFromJid(self.connection.jid)) {
// .connected is true while connecting?
self.connection.send($pres());
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_ESTABLISHED,
Strophe.getResourceFromJid(self.connection.jid));
}
@ -130,6 +132,7 @@ XMPP.prototype._connect = function (jid, password) {
}
lastErrorMsg = msg;
} else if (status === Strophe.Status.DISCONNECTED) {
self.disconnectInProgress = false;
if (anonymousConnectionFailed) {
// prompt user for username and password
self.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_FAILED,
@ -165,7 +168,7 @@ XMPP.prototype.connect = function (jid, password) {
};
XMPP.prototype.joinRoom = function(roomName, useNicks, nick) {
var roomjid = roomName;
var roomjid = roomName + '@' + Strophe.getDomainFromJid(this.connection.jid);
if (useNicks) {
if (nick) {
@ -181,20 +184,9 @@ XMPP.prototype.joinRoom = function(roomName, useNicks, nick) {
roomjid += '/' + tmpJid;
}
this.connection.emuc.doJoin(roomjid);
return this.connection.emuc.doJoin(roomjid, null, this.eventEmitter);
};
XMPP.prototype.myJid = function () {
if(!this.connection)
return null;
return this.connection.emuc.myroomjid;
}
XMPP.prototype.myResource = function () {
if(!this.connection || ! this.connection.emuc.myroomjid)
return null;
return Strophe.getResourceFromJid(this.connection.emuc.myroomjid);
}
XMPP.prototype.disposeConference = function (onUnload) {
var handler = this.connection.jingle.activecall;
@ -227,8 +219,8 @@ XMPP.prototype.removeListener = function (type, listener) {
this.eventEmitter.removeListener(type, listener);
};
XMPP.prototype.leaveRoom = function () {
this.connection.emuc.doLeave();
XMPP.prototype.leaveRoom = function (jid) {
this.connection.emuc.doLeave(jid);
};
@ -330,43 +322,6 @@ XMPP.prototype.sendAudioInfoPresence = function(mute, callback) {
return true;
};
XMPP.prototype.addToPresence = function (name, value, dontSend) {
switch (name) {
case "displayName":
this.connection.emuc.addDisplayNameToPresence(value);
break;
case "prezi":
this.connection.emuc.addPreziToPresence(value, 0);
break;
case "preziSlide":
this.connection.emuc.addCurrentSlideToPresence(value);
break;
case "connectionQuality":
this.connection.emuc.addConnectionInfoToPresence(value);
break;
case "email":
this.connection.emuc.addEmailToPresence(value);
break;
case "devices":
this.connection.emuc.addDevicesToPresence(value);
break;
case "videoType":
this.connection.emuc.addVideoTypeToPresence(value);
break;
case "startMuted":
if(!Moderator.isModerator())
return;
this.connection.emuc.addStartMutedToPresence(value[0],
value[1]);
break;
default :
console.log("Unknown tag for presence: " + name);
return;
}
if (!dontSend)
this.connection.emuc.sendPresence();
};
/**
* Sends 'data' as a log message to the focus. Returns true iff a message
* was sent.
@ -408,17 +363,6 @@ XMPP.prototype.getXmppLog = function () {
return this.connection.logger ? this.connection.logger.log : null;
};
XMPP.prototype.sendChatMessage = function (message, nickname) {
this.connection.emuc.sendMessage(message, nickname);
};
XMPP.prototype.setSubject = function (topic) {
this.connection.emuc.setSubject(topic);
};
XMPP.prototype.lockRoom = function (key, onSuccess, onError, onNotSupported) {
this.connection.emuc.lockRoom(key, onSuccess, onError, onNotSupported);
};
XMPP.prototype.dial = function (to, from, roomName,roomPass) {
this.connection.rayo.dial(to, from, roomName,roomPass);
@ -436,25 +380,12 @@ XMPP.prototype.logout = function (callback) {
Moderator.logout(callback);
};
XMPP.prototype.findJidFromResource = function (resource) {
return this.connection.emuc.findJidFromResource(resource);
};
XMPP.prototype.getMembers = function () {
return this.connection.emuc.members;
};
XMPP.prototype.getJidFromSSRC = function (ssrc) {
if (!this.isConferenceInProgress())
return null;
return this.connection.jingle.activecall.getSsrcOwner(ssrc);
};
// Returns true iff we have joined the MUC.
XMPP.prototype.isMUCJoined = function () {
return this.connection.emuc.joined;
};
XMPP.prototype.getSessions = function () {
return this.connection.jingle.sessions;
};
@ -466,13 +397,13 @@ XMPP.prototype.removeStream = function (stream) {
};
XMPP.prototype.disconnect = function (callback) {
if (disconnectInProgress || !this.connection || !this.connection.connected)
if (this.disconnectInProgress || !this.connection || !this.connection.connected)
{
this.eventEmitter.emit(JitsiConnectionEvents.WRONG_STATE);
return;
}
disconnectInProgress = true;
this.disconnectInProgress = true;
this.connection.disconnect();
};