Skip to content

Commit

Permalink
feat(scan): autoreconnect to server
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 24, 2020
1 parent 2b33ae6 commit 09ed24d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 0 additions & 2 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module.exports = {
},

io: {
reconnection: true,
reconnectionDelayMax: 10000,
sockets: [{
name: 'main',
url: process.env.SERVER_URL || 'http://localhost:5301'
Expand Down
18 changes: 11 additions & 7 deletions pages/scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default {
},
submitEvents(key) {
console.log('this.socket: ', this.socket);
// console.log('this.socket: ', this.socket);
// log to "terminal"
this.socket.on("status" + key, (msg, cb) => {
Expand Down Expand Up @@ -219,22 +219,26 @@ export default {
async mounted() {
this.socket = this.$nuxtSocket({
channel: "/",
reconnection: true,
reconnectionDelayMax: 10000,
teardown: false,
});
/* Listen for events: */
/* this.socket.on("disconnect", () => {
this.socket.on("connect", () => {
this.socket.emit('auth', this.$store.state.user);
});
this.socket.on("disconnect", () => {
this.log.push('server disconnected');
this.running = '';
});
this.socket.on("reconnect_attempt", () => {
this.log.push('server reconnected');
this.log.push('try to connect ' + this.serverUrl + '...');
});
this.socket.on("reconnect", () => {
this.log.push('server reconnected');
}); */
firebase.auth().onAuthStateChanged(user => {
// if (!user) user = { uid: 'anon' + Math.random() * 100000}
this.socket.emit('auth', this.$store.state.user);
Expand Down

0 comments on commit 09ed24d

Please sign in to comment.