Skip to content

Commit

Permalink
fix(tuna-obs): partially fix #1596
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Jan 16, 2024
1 parent c84ea25 commit c9b96f0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/plugins/tuna-obs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default createPlugin({
enabled: false,
},
backend: {
liteMode: false,
data: {
cover: '',
cover_url: '',
Expand All @@ -51,18 +52,28 @@ export default createPlugin({
const url = `http://127.0.0.1:${port}/`;
net
.fetch(url, {
method: 'POST',
method: this.liteMode ? 'OPTIONS' : 'POST',
headers,
keepalive: true,
body: JSON.stringify({ data }),
body: this.liteMode ? undefined : JSON.stringify({ data }),
})
.then(() => {
if (this.liteMode) {
this.liteMode = false;
console.debug(
`obs-tuna webserver at port ${port} is now accessible. disable lite mode`,
);
post(data);
}
})
.catch((error: { code: number; errno: number }) => {
if (is.dev()) {
if (!this.liteMode && is.dev()) {
console.debug(
`Error: '${
error.code || error.errno
}' - when trying to access obs-tuna webserver at port ${port}`,
}' - when trying to access obs-tuna webserver at port ${port}. enable lite mode`,
);
this.liteMode = true;
}
});
};
Expand Down

0 comments on commit c9b96f0

Please sign in to comment.