Update PiPedalModel.tsx
vite/src/pipedal/PiPedalModel.tsx - For this file only!
Expected outcome is that the server may (or may not) reboot). The purpose of the catch handler (which would happen in the case of a socket disconnect) is to make sure that an error or abort does not get reported, since it is expected.
Changes to wifi configuration, where the handler code MUST NOT PROPAGATE AN EXCEPTION.
(1) just leave this function to rot in its shameful state of decay, but do NOT relay the error.
(2) Write the audio properties (specifically) without waiting for a response. The settings are propagated to other clients (and ourselves) with a on...changed notifications from the server, so there's no actual response from the server required.
Audio properties specified:
const audioProps = [
"http://two-play.com/plugins/toob-player#audioFile",
"http://two-play.com/plugins/toob-player#loop",
"http://two-play.com/plugins/toob-player#seek",
];
This commit is contained in:
@@ -2343,6 +2343,22 @@ export class PiPedalModel //implements PiPedalModel
|
||||
}
|
||||
}
|
||||
setPatchProperty(instanceId: number, uri: string, value: any): Promise<boolean> {
|
||||
// Audio related properties are written without waiting for a reply.
|
||||
// These URIs correspond to Toob player audio state. The server
|
||||
// broadcasts changes via on...changed messages, so we don't
|
||||
// need to wait for the reply when updating them.
|
||||
const audioProps = [
|
||||
"http://two-play.com/plugins/toob-player#audioFile",
|
||||
"http://two-play.com/plugins/toob-player#loop",
|
||||
"http://two-play.com/plugins/toob-player#seek",
|
||||
];
|
||||
if (audioProps.indexOf(uri) >= 0) {
|
||||
if (this.webSocket) {
|
||||
this.webSocket.send("setPatchProperty", { instanceId: instanceId, propertyUri: uri, value: value });
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
let result = new Promise<boolean>((resolve, reject) => {
|
||||
if (this.webSocket) {
|
||||
this.webSocket.request<boolean>(
|
||||
@@ -2983,7 +2999,7 @@ export class PiPedalModel //implements PiPedalModel
|
||||
// notify the server.
|
||||
let ws = this.webSocket;
|
||||
if (!ws) {
|
||||
reject("Not connected.");
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
ws.request<void>(
|
||||
@@ -2994,7 +3010,8 @@ export class PiPedalModel //implements PiPedalModel
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
// ignore expected disconnects/errors
|
||||
resolve();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -3049,7 +3066,8 @@ export class PiPedalModel //implements PiPedalModel
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
// ignore expected disconnects/errors
|
||||
resolve();
|
||||
});
|
||||
//resolve();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user