Skip to content

Commit 2eb27c3

Browse files
committed
changed: module status update logic now shows status 'OK' unless an error occurs
1 parent ea72f3c commit 2eb27c3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
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: 8 additions & 8 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) => {
@@ -144,18 +149,13 @@ export class WingInstance extends InstanceBase<WingConfig> implements InstanceBa
144149
})
145150

146151
this.connection?.on('message', (msg: OscMessage) => {
152+
this.updateStatus(InstanceStatus.Ok)
147153
if (this.connected == false) {
148-
this.updateStatus(InstanceStatus.Ok)
149154
this.connected = true
150155

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)