🐛 Site > Reset socket connections when changing project

This commit is contained in:
brunosimon
2017-12-25 18:42:13 +01:00
parent bcdd1447a0
commit b5d11bdde0
3 changed files with 26 additions and 9 deletions
+25 -6
View File
@@ -65,10 +65,22 @@ export default
return return
} }
// Project socket // Set null file
const projectURL = `${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:1571'}/project/${value.slug}` this.$store.commit('setFile', null)
this.projectSocket = socketIoClient(projectURL) // If was connected to another socket
if(this.projectSocket)
{
this.projectSocket.off('connect')
this.projectSocket.off('update_project')
this.projectSocket.off('create_file')
this.projectSocket.off('delete_file')
this.projectSocket.off('createVersion')
this.projectSocket.disconnect()
}
// Create new socket connexion
this.projectSocket = socketIoClient(`${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:1571'}/project/${value.slug}`)
this.projectSocket.on('connect', () => this.projectSocket.on('connect', () =>
{ {
@@ -95,10 +107,17 @@ export default
this.$store.commit('createVersion', data) this.$store.commit('createVersion', data)
}) })
// Chat socket // If was connected to another socket
const chatURL = `${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:1571'}/project/${value.slug}/chat` if(this.chatSocket)
{
this.chatSocket.off('connect')
this.chatSocket.off('user')
this.chatSocket.off('message')
this.chatSocket.disconnect()
}
this.chatSocket = socketIoClient(chatURL) // Chat socket
this.chatSocket = socketIoClient(`${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:1571'}/project/${value.slug}/chat`)
this.chatSocket.on('connect', () => this.chatSocket.on('connect', () =>
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Mon super site</title> <title>Mon super site trop bien</title>
</head> </head>
<body> <body>
<section> <section>
-2
View File
@@ -5,8 +5,6 @@
*/ */
class ClassName extends AnotherClass class ClassName extends AnotherClass
{ {
function __construct( argument ) function __construct( argument )
{ {
// code... // code...