Skip to content

Commit

Permalink
fix: avoid crash of Sisyfos when selecting Lawo and Studer premilary …
Browse files Browse the repository at this point in the history
…protocols
  • Loading branch information
olzzon authored and olzzon committed Feb 15, 2020
1 parent 028d666 commit d130205
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions server/utils/mixerConnections/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const DeviceTree = require('emberplus')
//@ts-ignore
import { DeviceTree, Ember} from 'emberplus'
import { store, state } from '../../reducers/store'
import { huiRemoteConnection } from '../../mainClasses'

//Utils:
import { IMixerProtocol } from '../../constants/MixerProtocolInterface';
import { IStore } from '../../reducers/indexReducer';
import {
SET_FADER_LEVEL,
SET_CHANNEL_LABEL
} from '../../reducers/faderActions'
import { logger } from '../logger';


export class EmberMixerConnection {
Expand All @@ -21,36 +22,53 @@ export class EmberMixerConnection {
constructor(mixerProtocol: IMixerProtocol) {
this.sendOutMessage = this.sendOutMessage.bind(this);
this.pingMixerCommand = this.pingMixerCommand.bind(this);

this.emberNodeObject = new Array(200);
this.mixerProtocol = mixerProtocol;


logger.info("Setting up Ember connection")
this.emberConnection = new DeviceTree(
state.settings[0].deviceIp,
state.settings[0].devicePort
);
let deviceRoot: any;
this.emberConnection.connect()
.then(() => {
console.log("Getting Directory")
return this.emberConnection.getDirectory();
})
.then((r: any) => {
console.log("Directory :", r);
this.deviceRoot = r;
this.emberConnection.expand(r.elements[0])
state.settings[0].deviceIp,
state.settings[0].devicePort
);

this.emberConnection.on('error', (error: any) => {
if (
(error.message + '').match(/econnrefused/i) ||
(error.message + '').match(/disconnected/i)
) {
logger.error('Ember connection not establised')
} else {
logger.error('Ember connection unknown error' + error.message)
}
})
this.emberConnection.on('connected', () => {
logger.info('Ember connected')
let deviceRoot: any;
this.emberConnection.connect()
.then(() => {
this.setupMixerConnection();
console.log("Getting Directory")
return this.emberConnection.getDirectory();
})
})
.catch((e: any) => {
console.log(e.stack);
});
.then((r: any) => {
console.log("Directory :", r);
this.deviceRoot = r;
this.emberConnection.expand(r.elements[0])
.then(() => {
this.setupMixerConnection();
})
})
.catch((e: any) => {
console.log(e.stack);
});
})
this.emberConnection.on('disconnected', () => {
logger.error('Lost Ember connection')
})

}

setupMixerConnection() {
console.log("Ember Connected");

let ch: number = 1;
state.settings[0].numberOfChannelsInType.forEach((numberOfChannels, typeIndex) => {
Expand Down

0 comments on commit d130205

Please sign in to comment.