增加用户地址信息

master
“zhenQin” 8 years ago
parent d2ec150fad
commit 90c80f70d5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

@ -11,9 +11,9 @@ HiChat.prototype = {
var _pic=document.body.querySelectorAll("#nickWrapper .img-list li.checked img")[0].src;
var curUser={
nickName:"我",
pic:_pic
pic:_pic,
address:""
}
console.log(curUser);
this.socket = io.connect();
this.socket.on('connect', function() {
document.getElementById('info').textContent = '请输入一个昵称:';
@ -43,12 +43,11 @@ HiChat.prototype = {
var listDiv=document.getElementById("online-list");
var str="";
for (var i=0;i<users.length;i++){
str+="<li class='user-span'><img src='"+users[i].pic+"'><div>"+users[i].nickName+"</div></li>";
str+="<li class='user-span' title='"+users[i].address+"'><img src='"+users[i].pic+"'><div>"+users[i].nickName+"</div></li>";
}
listDiv.innerHTML=str;
});
this.socket.on('newMsg', function(user, msg, color) {
console.log(user);
that._displayMsg(user, msg, color,"msg");
});
this.socket.on('newImg', function(user, img, color) {

@ -14,6 +14,8 @@ io.sockets.on('connection', function(socket) {
if (isHave(user)) {
socket.emit('nickExisted');
} else {
var address=socket.handshake.address.address+":"+socket.handshake.address.port;
user.address=address;
socket.userIndex = users.length;
socket.user = user;
users.push(user);

Loading…
Cancel
Save