Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #84 from speckleworks/Dim/dev/client-ws-fixes
Browse files Browse the repository at this point in the history
waits for login flow to be finalised before it loads url streams
  • Loading branch information
didimitrie authored Nov 26, 2018
2 parents 0df0ce7 + c4f907a commit a2b7caa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ export default {
this.viewerSettings = this.$store.getters.viewerSettings
this.$store.state.initStreams.forEach( streamId => {
this.addReceiver( streamId )
bus.$on( 'login-flow-finalised', ( ) => {
this.$store.state.initStreams.forEach( streamId => {
this.addReceiver( streamId )
} )
} )
bus.$on( 'snackbar-update', this.snackbarUpdate )
bus.$on( 'stream-load-progress', message => {
this.progressMessage = message
Expand Down
1 change: 1 addition & 0 deletions src/components/SidebarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default {
this.$store.commit( 'SET_USER', { account } )
this.showLogin = false
}
bus.$emit( 'login-flow-finalised' )
},
getStreams( ) {
var jwtToken = localStorage.getItem( 'token' )
Expand Down
5 changes: 4 additions & 1 deletion src/receiver/ClientReceiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class SpeckleReceiver extends EventEmitter {
axios.delete( `${this.baseUrl}/clients/${this.clientId}` )
.then( response => {
this.clientId = null
clearInterval( this.wsConnectionChecker )
this.ws.close( )
} )
.catch( err => {
Expand All @@ -58,7 +59,9 @@ export default class SpeckleReceiver extends EventEmitter {
}

this.ws.onmessage = message => {
if ( message.data === 'ping' ) return this.ws.send( 'alive' )
if ( message.data === 'ping' ) {
return this.ws.send( 'alive' )
}
let parsedMessage = JSON.parse( message.data )
switch ( parsedMessage.args.eventType ) {
case 'update-global':
Expand Down

0 comments on commit a2b7caa

Please sign in to comment.