improve chat
This commit is contained in:
parent
2ae3d43354
commit
61ae57a850
14 changed files with 306 additions and 33 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue