improve chat

This commit is contained in:
Asraelite 2016-03-28 13:16:38 +01:00
parent 2ae3d43354
commit 61ae57a850
14 changed files with 306 additions and 33 deletions

View file

@ -15,7 +15,7 @@ class Connection {
this.chatCooldown = 0;
socket.on('chat', data => {
this.chat(data);
this.player.chat(data);
});
socket.on('setName', data => {
@ -33,20 +33,6 @@ class Connection {
this.server.assignRoom(this.player);
}
chat(data) {
//if(this.chatCooldown > 5 || !this.room) return;
if(!data.msg) return;
wingbase.log(`${this.room}/${this.player.name}: ${data.msg}`);
this.chatCooldown++;
this.io.to(this.room).emit('chat', {
type: 'player',
source: this.player.name,
message: data.msg.slice(0, 100)
});
}
disconnect() {
this.socket.disconnect();
this.player.disconnect();