App > Stop listening to socket events

This commit is contained in:
brunosimon
2019-06-05 23:36:59 +02:00
parent 2a9a4ca2e1
commit 6338fc8ac8
6 changed files with 95 additions and 37 deletions
+15 -3
View File
@@ -43,8 +43,9 @@ class Project
// Create a channel for this specific project
this.projectSocket = this.config.socket.of('/project/' + this.slug)
// Connection event
this.projectSocket.on('connection', (socket) =>
// Callbacks
this.socketCallbacks = {}
this.socketCallbacks.connection = (socket) =>
{
this.projectSocket.emit('update_project', this.describe())
@@ -53,7 +54,10 @@ class Project
{
console.log(`${chalk.green.bold('project > socket')} - ${chalk.cyan('connection')} - ${chalk.cyan(socket.id)}`)
}
})
}
// Connection event
this.projectSocket.on('connection', this.socketCallbacks.connection)
}
getZipBuffer()
@@ -306,6 +310,14 @@ class ClassName extends AnotherClass
destructor()
{
// Destroy chat and files
this.files.destructor()
this.chat.destructor()
// Stop listening
this.projectSocket.off('connection', this.socketCallbacks.connection)
// Emit event
this.projectSocket.emit('destruct')
}
}