Skip to content

Instantly share code, notes, and snippets.

@kristianpedersen
Created September 14, 2020 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianpedersen/20a53baa554e1afef63ca993110a0cb4 to your computer and use it in GitHub Desktop.
Save kristianpedersen/20a53baa554e1afef63ca993110a0cb4 to your computer and use it in GitHub Desktop.
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