showing who is replying in the active users block

This commit is contained in:
Julian Lam
2014-03-01 15:46:13 -05:00
parent ea222a4295
commit b3d7ae1c86
3 changed files with 53 additions and 2 deletions

View File

@@ -18,7 +18,9 @@ var posts = require('../posts'),
/* Posts Composer */
SocketModules.composer = {};
SocketModules.composer = {
replyHash: {}
};
SocketModules.composer.push = function(socket, pid, callback) {
if (socket.uid || parseInt(meta.config.allowGuestPosting, 10)) {
@@ -74,6 +76,27 @@ SocketModules.composer.renderHelp = function(socket, data, callback) {
plugins.fireHook('filter:composer.help', '', callback);
};
SocketModules.composer.register = function(socket, data) {
server.in('topic_' + data.tid).emit('event:topic.replyStart', data.uid);
data.socket = socket;
data.timer = setInterval(function() {
// Ping the socket to see if the composer is still active
socket.emit('event:composer.ping', data.uuid);
}, 1000*10); // Every 10 seconds...
SocketModules.composer.replyHash[data.uuid] = data;
};
SocketModules.composer.pingInactive = function(socket, uuid) {
var data = SocketModules.composer.replyHash[uuid];
if (SocketModules.composer.replyHash[uuid]) {
server.in('topic_' + data.tid).emit('event:topic.replyStop', data.uid);
clearInterval(data.timer);
delete SocketModules.composer.replyHash[uuid];
}
};
/* Chat */
SocketModules.chats = {};