Answer the question
In order to leave comments, you need to log in
How to trace a socket.io connection?
Good evening gentlemen!
In the component, I'm trying to track the state of the socket, and display a notification about the status of the connection.
<template>
</template>
<script>
export default {
name: "MessageComponent"
};
var vm = new Vue({
sockets:{
connect: function(){
this.$vs.notify({title:'Соединение',text:'Вы успешно подключились к чату!',color:'success',position:'bottom-center'});
}
},
});
</script>
<style scoped>
</style>
Failed to load resource: net::ERR_CONNECTION_REFUSED
Answer the question
In order to leave comments, you need to log in
I found observer statuses and caught the error like this. If you are interested, you can see all other statuses in the docks :)
export default {
mounted() {
var vm = new Vue({
sockets:{
connect: function(){
this.$vs.notify({title:'Соединение',text:'Вы успешно подключились к чату!',color:'success',position:'bottom-center'});
},
connect_error: function(){
this.$vs.notify({title:'Соединение',text:'Ошибка сервера, не могу подключить к чату!',color:'danger',position:'bottom-center'});
}
}
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question