changes for live streaming of posts

v1.18.x
barisusakli 11 years ago
parent 1e9850b6b9
commit 813b3d6fcc

@ -4,7 +4,8 @@ var socket,
'username': null,
'uid': null,
'isFocused': true,
'currentRoom': null
'currentRoom': null,
'widgets': {}
};
(function () {

@ -3,23 +3,29 @@
define(function() {
var home = {};
$(window).on('action:ajaxify.end', function(ev, data) {
if (data.url === '') {
socket.removeListener('event:new_topic', home.onNewTopic);
socket.removeListener('event:new_post', home.onNewPost);
}
});
home.init = function() {
app.enterRoom('home');
ajaxify.register_events([
'event:new_topic',
'event:new_post'
]);
socket.on('event:new_topic', home.onNewTopic);
socket.on('event:new_post', home.onNewPost);
};
socket.on('event:new_topic', function(data) {
home.onNewTopic = function(data) {
});
};
socket.on('event:new_post', function(data) {
home.onNewPost = function(data) {
});
}
};
return home;
});

@ -329,7 +329,7 @@ var db = require('./database'),
if(stripTags) {
var s = S(content);
postData.content = s.stripTags.apply(s, utils.getTagsExcept(['img', 'i'])).s;
postData.content = s.stripTags.apply(s, utils.getTagsExcept(['img', 'i', 'p'])).s;
} else {
postData.content = content;
}

@ -71,10 +71,7 @@ SocketPosts.reply = function(socket, data, callback) {
posts: [postData]
};
var rooms = ['recent_posts', 'home', 'topic_' + postData.tid, 'user/' + postData.uid];
rooms.forEach(function(room) {
index.server.sockets.in(room).emit('event:new_post', socketData);
});
index.server.sockets.emit('event:new_post', socketData);
callback();
}
@ -326,4 +323,9 @@ SocketPosts.loadMoreUserPosts = function(socket, data, callback) {
posts.getPostsByUid(socket.uid, data.uid, start, end, callback);
};
SocketPosts.getRecentPosts = function(socket, term, callback) {
posts.getRecentPosts(socket.uid, 0, 19, term, callback);
};
module.exports = SocketPosts;

@ -3,7 +3,7 @@ var winston = require('winston');
var SocketTools = {};
SocketTools.log = function(socket, data, callback) {
winston.info("captured console.log:", data)
//winston.info("captured console.log:", data)
};
module.exports = SocketTools;

@ -61,6 +61,9 @@ SocketTopics.post = function(socket, data, callback) {
index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData);
index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData);
index.server.sockets.in('home').emit('event:new_topic', result.topicData);
index.server.sockets.in('home').emit('event:new_post', {
posts: result.postData
});
index.server.sockets.in('user/' + socket.uid).emit('event:new_post', {
posts: result.postData
});

Loading…
Cancel
Save