parent
76e50e2c4d
commit
2c855de6f6
|
@ -35,6 +35,7 @@ var messageLogger = log4js.getLogger("message");
|
||||||
var accessLogger = log4js.getLogger("access");
|
var accessLogger = log4js.getLogger("access");
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js");
|
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js");
|
||||||
|
var channels = require("channels");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A associative array that saves informations about a session
|
* A associative array that saves informations about a session
|
||||||
|
@ -48,6 +49,11 @@ var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js");
|
||||||
*/
|
*/
|
||||||
var sessioninfos = {};
|
var sessioninfos = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A changeset queue per pad that is processed by handleUserChanges()
|
||||||
|
*/
|
||||||
|
var padChannels = new channels.channels(handleUserChanges);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the Socket class we need to send and recieve data from the client
|
* Saves the Socket class we need to send and recieve data from the client
|
||||||
*/
|
*/
|
||||||
|
@ -176,7 +182,7 @@ exports.handleMessage = function(client, message)
|
||||||
if (sessioninfos[client.id].readonly) {
|
if (sessioninfos[client.id].readonly) {
|
||||||
messageLogger.warn("Dropped message, COLLABROOM for readonly pad");
|
messageLogger.warn("Dropped message, COLLABROOM for readonly pad");
|
||||||
} else if (message.data.type == "USER_CHANGES") {
|
} else if (message.data.type == "USER_CHANGES") {
|
||||||
handleUserChanges(client, message);
|
padChannels.emit(message.padId, {client: client, message: message});// add to pad queue
|
||||||
} else if (message.data.type == "USERINFO_UPDATE") {
|
} else if (message.data.type == "USERINFO_UPDATE") {
|
||||||
handleUserInfoUpdate(client, message);
|
handleUserInfoUpdate(client, message);
|
||||||
} else if (message.data.type == "CHAT_MESSAGE") {
|
} else if (message.data.type == "CHAT_MESSAGE") {
|
||||||
|
@ -522,23 +528,26 @@ function handleUserInfoUpdate(client, message)
|
||||||
* @param client the client that send this message
|
* @param client the client that send this message
|
||||||
* @param message the message from the client
|
* @param message the message from the client
|
||||||
*/
|
*/
|
||||||
function handleUserChanges(client, message)
|
function handleUserChanges(data, cb)
|
||||||
{
|
{
|
||||||
|
var client = data.client
|
||||||
|
, message = data.message
|
||||||
|
|
||||||
// Make sure all required fields are present
|
// Make sure all required fields are present
|
||||||
if(message.data.baseRev == null)
|
if(message.data.baseRev == null)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, USER_CHANGES Message has no baseRev!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no baseRev!");
|
||||||
return;
|
return cb();
|
||||||
}
|
}
|
||||||
if(message.data.apool == null)
|
if(message.data.apool == null)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no apool!");
|
||||||
return;
|
return cb();
|
||||||
}
|
}
|
||||||
if(message.data.changeset == null)
|
if(message.data.changeset == null)
|
||||||
{
|
{
|
||||||
messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!");
|
messageLogger.warn("Dropped message, USER_CHANGES Message has no changeset!");
|
||||||
return;
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
//get all Vars we need
|
//get all Vars we need
|
||||||
|
@ -679,6 +688,7 @@ function handleUserChanges(client, message)
|
||||||
}
|
}
|
||||||
], function(err)
|
], function(err)
|
||||||
{
|
{
|
||||||
|
cb();
|
||||||
ERR(err);
|
ERR(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
"underscore" : "1.3.1",
|
"underscore" : "1.3.1",
|
||||||
"unorm" : "1.0.0",
|
"unorm" : "1.0.0",
|
||||||
"languages4translatewiki" : "0.1.3",
|
"languages4translatewiki" : "0.1.3",
|
||||||
"swagger-node-express" : "1.2.3"
|
"swagger-node-express" : "1.2.3",
|
||||||
|
"channels" : "0.0.x"
|
||||||
},
|
},
|
||||||
"bin": { "etherpad-lite": "./node/server.js" },
|
"bin": { "etherpad-lite": "./node/server.js" },
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in New Issue