More fixes
This commit is contained in:
parent
6570c3da6c
commit
0f82faaef8
3 changed files with 33 additions and 3 deletions
|
|
@ -1137,6 +1137,20 @@ Channel.prototype.sendRecentChat = function (users) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a user profile
|
||||
*/
|
||||
Channel.prototype.sendUserProfile = function (users, user) {
|
||||
var packet = {
|
||||
name: user.name,
|
||||
profile: user.profile
|
||||
};
|
||||
|
||||
users.forEach(function (u) {
|
||||
u.socket.emit("setUserProfile", packet);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Packs userdata for addUser or userlist
|
||||
*/
|
||||
|
|
|
|||
12
lib/user.js
12
lib/user.js
|
|
@ -58,6 +58,18 @@ function User(socket) {
|
|||
if (announcement != null) {
|
||||
self.socket.emit("announcement", announcement);
|
||||
}
|
||||
|
||||
self.on("login", function () {
|
||||
db.recordVisit(self.ip, self.name);
|
||||
db.users.getProfile(self.name, function (err, profile) {
|
||||
if (!err) {
|
||||
self.profile = profile;
|
||||
if (self.inChannel()) {
|
||||
self.channel.sendUserProfile(self.channel.users, self);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue