Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.
/ scenic Public archive

Commit

Permalink
Add change_picture handler and notice.
Browse files Browse the repository at this point in the history
Server-side handler for picture changing, and
add the notice about picture changing for users.
  • Loading branch information
HyeonJe Jun committed Nov 19, 2012
1 parent 87457ca commit 5d5155a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ module.exports = {
_.each(this.users, function(user) {
user.socket.emit('picture_changed', {pid: picture._id, width: picture.width, height: picture.height});
});
this.notice('Picture has been changed to '+picture._id);
};
}
};
10 changes: 10 additions & 0 deletions server/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ function Socket(web) {
user.say(data.msg);
});

socket.on('change_picture', function(data) {
if(channels[data.channel]) {
PictureModel.findOne({_id: data.pid}, function(err, picture) {
if(picture !== null) {
channels[data.channel].changePicture(picture);
}
});
}
});

socket.on('change_nick', function(data) {
if(!user) {
socket.emit('error', {type: 'NoUser'});
Expand Down

0 comments on commit 5d5155a

Please sign in to comment.