forked from OwnZones/orchestration-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bug-solve and addressed feedback
- Loading branch information
Showing
14 changed files
with
222 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
const wsUrl = `ws://${process.env.CONTROL_PANEL_WS}`; | ||
|
||
export async function POST(request: Request) { | ||
const { action, inputSlot } = await request.json(); | ||
|
||
if (!wsUrl) { | ||
return NextResponse.json( | ||
{ message: 'WebSocket URL is not defined' }, | ||
{ status: 500 } | ||
); | ||
} | ||
|
||
return new Promise((resolve) => { | ||
const ws = new WebSocket(wsUrl); | ||
|
||
ws.onopen = () => { | ||
if (action === 'closeHtml') { | ||
ws.send(`html close ${inputSlot}`); | ||
ws.send('html reset'); | ||
} else if (action === 'closeMediaplayer') { | ||
ws.send(`media close ${inputSlot}`); | ||
ws.send('media reset'); | ||
} | ||
ws.close(); | ||
}; | ||
|
||
ws.onerror = (error) => { | ||
resolve( | ||
NextResponse.json( | ||
{ message: 'WebSocket error', error }, | ||
{ status: 500 } | ||
) | ||
); | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.