Created
September 14, 2020 08:18
-
-
Save kristianpedersen/20a53baa554e1afef63ca993110a0cb4 to your computer and use it in GitHub Desktop.
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
const httpIP = "http://172.20.66.181" | |
const app = require('express')() | |
const axios = require("axios") | |
const exec = require("child_process").exec | |
const http = require('http').createServer(app) | |
const io = require('socket.io')(http) | |
app.get('/', function serveIndexHtml(_, res) { | |
res.sendFile(__dirname + '/index.html') | |
}) | |
// Receive data from browser | |
io.on('connection', function ioOnConnection(socket) { | |
socket.on("record", async () => { | |
await axios.post(`http://172.20.66.181/control/startRecording`) | |
await new Promise(resolve => setTimeout(resolve, 1000)) | |
await axios.post(`http://172.20.66.181/control/stopRecording`) | |
}) | |
socket.on("play", () => { | |
setTimeout(() => { | |
const args = "--header \"Content-Type: application/json\" --request POST --data \'{\"framerate\":60, \"position\":0}\' http://172.20.66.181/control/startPlayback" | |
exec("curl " + args) | |
console.log("play") | |
}, 1000) | |
}) | |
socket.on("test", () => console.log("Omglog")) | |
}) | |
http.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment