Skip to content

Commit

Permalink
fix: OSC protocol - set mixer online when auto reconnecting
Browse files Browse the repository at this point in the history
fix: updateMixerOnline - add optional updateState in MainThread handler, to prevent the risk of store not updating because of async store.
  • Loading branch information
olzzon committed Feb 24, 2021
1 parent bc292d4 commit 18ac6c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ export class MainThreadHandlers {
})
}

updateMixerOnline(mixerIndex: number) {
updateMixerOnline(mixerIndex: number, onLineState?: boolean) {
socketServer.emit(SOCKET_SET_MIXER_ONLINE, {
mixerIndex,
mixerOnline: state.settings[0].mixers[mixerIndex].mixerOnline,
mixerOnline:
onLineState ?? state.settings[0].mixers[mixerIndex].mixerOnline,
})
}

Expand Down
5 changes: 4 additions & 1 deletion server/utils/mixerConnections/OscMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class OscMixerConnection {

mixerOnline(onLineState: boolean) {
store.dispatch(storeSetMixerOnline(this.mixerIndex, onLineState))
global.mainThreadHandler.updateMixerOnline(this.mixerIndex)
global.mainThreadHandler.updateMixerOnline(this.mixerIndex, onLineState)
}

setupMixerConnection() {
Expand All @@ -85,6 +85,9 @@ export class OscMixerConnection {
})
.on('message', (message: any) => {
clearTimeout(this.mixerOnlineTimer)
if (!state.settings[0].mixers[this.mixerIndex].mixerOnline) {
this.mixerOnline(true)
}
logger.verbose('Received OSC message: ' + message.address, {})

if (
Expand Down

0 comments on commit 18ac6c0

Please sign in to comment.