summaryrefslogtreecommitdiff
path: root/public/assets/js/app.js
blob: 0ea5eeb71ebc452375ac1268e62a3ad6221ff96d (plain)
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 container = document.querySelector('#container')

let socket = io.connect('/client')
let got_frame = false

socket.on('res', (data) => {
  console.log(data)
})

socket.on('frame', (data) => {
  got_frame = true
  console.log('frame', data.fn)
  // console.log(data.frame)
  // return
  const blob = new Blob([data.frame], { type: 'image/jpg' })
  const url = URL.createObjectURL(blob)

  const img = new Image ()
  img.onload = function() {
    URL.revokeObjectURL(url)
    container.innerHTML = ''
    container.appendChild(img)
  }
  img.src = url
})

socket.emit('cmd', {
  cmd: 'get_params',
})

setTimeout(() => {
  if (!got_frame) {
    socket.emit('cmd', {
      cmd: 'get_last_frame',
    })
  }
}, 500)

socket.emit('cmd', {
  cmd: 'send_param',
  payload: {
    'key': 'client',
    'value': 'test',
  }
})