⚡ App > Stop listening to socket events
This commit is contained in:
+15
-3
@@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user