You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[HeosEvent and HeosResponse](#heosevent-and-heosresponse)
35
37
-[Documentation](#documentation)
36
38
-[Contributing](#contributing)
@@ -174,6 +176,34 @@ Exactly like [`connection.on()`](<#connection.on(event,-listener)>) but will onl
174
176
175
177
Exactly like [`connection.on()`](<#connection.on(event,-listener)>) but will trigger the listener for every response or event. It is useful for logging or debugging purposes. These listeners are triggered before any other as they can be useful for understanding why other listeners might be faulty.
176
178
179
+
#### connection.onClose(listener)
180
+
181
+
-`listener`: (hadError: boolean) => void
182
+
183
+
Adds an event listener for when the connection is closed. `hadError` is true if there was a transmission error.
184
+
185
+
```js
186
+
connection.onClose(hadError=> {
187
+
if (hadError) {
188
+
console.error('There was a transmission error and the connection closed.')
189
+
} else {
190
+
console.log('Connection closed')
191
+
}
192
+
})
193
+
```
194
+
195
+
#### connection.onError(listener)
196
+
197
+
-`listener`: (error: Error) => void
198
+
199
+
Adds an event listener for when an error occurs.
200
+
201
+
```js
202
+
connection.onError(error=> {
203
+
console.error(error)
204
+
})
205
+
```
206
+
177
207
#### HeosEvent and HeosResponse
178
208
179
209
The responses to commands are objects like this example:
0 commit comments