forked from OwnZones/orchestration-gui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Eyevinn/fix/start-prod-w-websocket
Solves the problem with starting productions with websocket-sources
- Loading branch information
Showing
37 changed files
with
889 additions
and
460 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
import WebSocket from 'ws'; | ||
|
||
function createWebSocket(): Promise<WebSocket> { | ||
return new Promise((resolve, reject) => { | ||
const ws = new WebSocket(`ws://${process.env.CONTROL_PANEL_WS}`); | ||
ws.on('error', reject); | ||
ws.on('open', () => { | ||
// const send = ws.send.bind(ws); | ||
// ws.send = (message) => { | ||
// console.debug(`[websocket] sending message: ${message}`); | ||
// send(message); | ||
// }; | ||
resolve(ws); | ||
}); | ||
}); | ||
} | ||
|
||
export async function createControlPanelWebSocket() { | ||
const ws = await createWebSocket(); | ||
return { | ||
createHtml: (input: number) => { | ||
ws.send(`html create ${input} 1920 1080`); | ||
}, | ||
createMediaplayer: (input: number) => { | ||
ws.send(`media create ${input} ${process.env.MEDIAPLAYER_PLACEHOLDER}`); | ||
}, | ||
closeHtml: (input: number) => { | ||
ws.send(`html close ${input}`); | ||
ws.send('html reset'); | ||
}, | ||
closeMediaplayer: (input: number) => { | ||
ws.send(`media close ${input}`); | ||
ws.send('media reset'); | ||
}, | ||
close: () => | ||
setTimeout(() => { | ||
ws.close(); | ||
}, 1000) | ||
}; | ||
} |
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
Oops, something went wrong.