Skip to content

Commit 8d7cd8d

Browse files
authored
Merge pull request #177 from bitfocus/fix-companion-status-logic
Fix module status logic
2 parents ea72f3c + a4e4f40 commit 8d7cd8d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/handlers/connection-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export class ConnectionHandler extends EventEmitter {
4545
this.emit('ready')
4646
})
4747

48-
this.osc.on('error', (err) => {
48+
this.osc.on('error', (err: Error) => {
4949
this.logger?.error(`OSC error: ${err.message}`)
50-
this.emit('error')
50+
this.emit('error', err)
5151
})
5252

5353
this.osc.on('close' as any, () => {

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ export class WingInstance extends InstanceBase<WingConfig> implements InstanceBa
126126
this.connection.open('0.0.0.0', 0, this.config.host!, 2223)
127127
this.connection.setSubscriptionInterval(this.config.subscriptionInterval ?? 9000)
128128
this.connection.startSubscription()
129+
this.updateStatus(InstanceStatus.Connecting, 'waiting for response from console...')
129130

130131
this.connection?.on('ready', () => {
131-
this.updateStatus(InstanceStatus.Connecting, 'waiting for response from console...')
132-
void this.connection?.sendCommand('/*', undefined, undefined, true) // send something to trigger response from console
132+
this.updateStatus(InstanceStatus.Ok)
133+
this.stateHandler?.state?.requestNames(this)
134+
if (this.config.prefetchVariablesOnStartup) {
135+
this.stateHandler?.state?.requestAllVariables(this)
136+
}
137+
this.stateHandler?.requestUpdate()
133138
})
134139

135140
this.connection?.on('error', (err: Error) => {
@@ -151,11 +156,6 @@ export class WingInstance extends InstanceBase<WingConfig> implements InstanceBa
151156
this.logger?.info('OSC connection established')
152157

153158
this.feedbackHandler?.startPolling()
154-
this.stateHandler?.state?.requestNames(this)
155-
if (this.config.prefetchVariablesOnStartup) {
156-
this.stateHandler?.state?.requestAllVariables(this)
157-
}
158-
this.stateHandler?.requestUpdate()
159159
}
160160
this.feedbackHandler?.clearPollTimeout()
161161
this.stateHandler?.processMessage(msg)

0 commit comments

Comments
 (0)