-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
45 lines (36 loc) · 1.06 KB
/
main.js
File metadata and controls
45 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const http = require('http')
const server = http.createServer()
console.log("\nUse chrome to connect 127.0.0.1:8000 to get Theta V preview\nwaiting...")
server.on('request', (_req,_res) =>
{
const data = '{"name": "camera.getLivePreview"}'
const options = {
hostname: '192.168.1.1',
port: 80,
path: '/osc/commands/execute',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}
const req = http.request(options, (res) => {
console.log("\nCamera is connected\n")
_res.writeHead(200,
{'Connection': 'Keep-Alive',
'Content-Type': 'multipart/x-mixed-replace; boundary="---osclivepreview---"',
'X-Content-Type-Options':'nosniff',
'Transfer-Encoding': 'Chunked'})
res.on('data', (d) => {
_res.write(d)
})
})
req.on('error', (error) => {
console.log('Error connecting ricoh camera')
_res.end('Error connecting ricoh camera')
})
req.write(data)
req.end()
}
)
server.listen(8000)