Site > Chat > Add user update

This commit is contained in:
brunosimon
2017-08-14 22:17:40 +02:00
parent 16052bd2ea
commit 0eb639a9db
9 changed files with 164 additions and 13 deletions
+7 -9
View File
@@ -42,11 +42,11 @@ class Chat
console.log('chat > user'.green.bold + ' - ' + 'create'.cyan + ' - ' + user.name.cyan)
}
// Send infos
// Send user infos
const broadcastUser = {}
broadcastUser.name = user.name
broadcastUser.color = user.color
socket.emit('infos', broadcastUser)
socket.emit('user', broadcastUser)
// On message
socket.on('message', (data) =>
@@ -74,8 +74,8 @@ class Chat
}
})
// On update infos
socket.on('update_infos', (data) =>
// On update user
socket.on('update_user', (data) =>
{
const newName = data.name.trim()
const oldName = user.name
@@ -92,7 +92,7 @@ class Chat
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'update_infos'.cyan + ' - ' + (oldName + ' > ' + user.name).cyan)
console.log('chat > socket'.green.bold + ' - ' + 'update_user'.cyan + ' - ' + (oldName + ' > ' + user.name).cyan)
}
})
@@ -161,11 +161,11 @@ class Chat
// Create user A
const userA = this.createUser()
// Send infos
// Send user infos
const broadcastUser = {}
broadcastUser.name = userA.name
broadcastUser.color = userA.color
this.chatSocket.emit('infos', broadcastUser)
this.chatSocket.emit('user', broadcastUser)
let counting = 0
setInterval(() =>
@@ -188,8 +188,6 @@ class Chat
broadcastMessage.user = userA
this.chatSocket.emit('message', broadcastMessage)
console.log('message')
}, 1500)
}
}