🐛 Site > Reset socket connections when changing project
This commit is contained in:
@@ -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', () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
class ClassName extends AnotherClass
|
class ClassName extends AnotherClass
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
function __construct( argument )
|
function __construct( argument )
|
||||||
{
|
{
|
||||||
// code...
|
// code...
|
||||||
|
|||||||
Reference in New Issue
Block a user