Skip to content

Commit

Permalink
fix: subscribe to VU meters upon connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Nov 12, 2020
1 parent c518510 commit bf5fce7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 0 additions & 3 deletions client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ socketClientHandlers()
window.socketIoClient.emit('get-store', 'update local store')
window.socketIoClient.emit('get-settings', 'update local settings')
window.socketIoClient.emit('get-mixerprotocol', 'get selected mixerprotocol')
if (!window.location.search.includes('vu=0')) {
window.socketIoClient.emit('subscribe-vu-meter', 'subscribe to vu meters')
}

ReactDom.render(
<ReduxProvider store={storeRedux}>
Expand Down
7 changes: 7 additions & 0 deletions client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export const socketClientHandlers = () => {
.on('connect', () => {
window.storeRedux.dispatch(storeSetServerOnline(true))
console.log('CONNECTED TO SISYFOS SERVER')
if (!window.location.search.includes('vu=0')) {
// subscribe to VU'
window.socketIoClient.emit(
'subscribe-vu-meter',
'subscribe to vu meters'
)
}
})
.on('disconnect', () => {
window.storeRedux.dispatch(storeSetServerOnline(false))
Expand Down
5 changes: 4 additions & 1 deletion server/utils/vuServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export enum VuType {
const sockets: Array<any> = []

export function socketSubscribeVu(socket: any) {
sockets.push(socket)
const i = sockets.indexOf(socket)
if (i === -1) {
sockets.push(socket)
}
}

export function socketUnsubscribeVu(socket: any) {
Expand Down

0 comments on commit bf5fce7

Please sign in to comment.