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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
import { store } from './store'
import types from './types'
import * as player from './live/player'
let socket = io.connect('/client')
// SOCKET ACTIONS
socket.on('res', (data) => {
console.log(data.cmd)
switch (data.cmd) {
case 'get_last_frame':
if (data.res !== 'working') {
socket.emit('cmd', {
cmd: 'get_last_frame',
})
}
break
case 'get_params':
store.dispatch({
type: types.socket.load_params,
opt: data.res,
})
break
case 'list_checkpoints':
store.dispatch({
type: types.socket.list_checkpoints,
checkpoints: data.res,
})
break
case 'list_sequences':
store.dispatch({
type: types.socket.list_sequences,
sequences: data.res,
})
break
case 'list_epochs':
store.dispatch({
type: types.socket.list_epochs,
epochs: data.res,
})
break
default:
break
}
console.log(data)
})
socket.on('system_res', (data) => {
console.log('system response', data)
switch (data.type) {
case 'command_output':
store.dispatch({
type: types.system.command_output,
data: data,
})
break
}
})
socket.on('frame', player.onFrame)
socket.on('status', (data) => {
console.log('got status', data.key, data.value)
store.dispatch({ type: types.socket.status })
switch (data.key) {
case 'processing':
store.dispatch({
type: 'SET_PARAM',
...data,
})
break
default:
break
}
})
export function list_checkpoints() {
socket.emit('cmd', {
cmd: 'list_checkpoints',
})
}
export function list_epochs(checkpoint_name) {
socket.emit('cmd', {
cmd: 'list_epochs',
payload: checkpoint_name,
})
}
export function list_sequences() {
socket.emit('cmd', {
cmd: 'list_sequences',
})
}
export function load_epoch(checkpoint_name, epoch) {
console.log(">> SWITCH CHECKPOINT", checkpoint_name, epoch)
socket.emit('cmd', {
cmd: 'load_epoch',
payload: checkpoint_name + ':' + epoch,
})
}
export function load_sequence(sequence) {
socket.emit('cmd', {
cmd: 'load_sequence',
payload: sequence,
})
}
export function seek(frame) {
socket.emit('cmd', {
cmd: 'seek',
payload: frame,
})
}
export function pause(frame) {
socket.emit('cmd', {
cmd: 'pause',
})
}
export function play(frame) {
socket.emit('cmd', {
cmd: 'play',
})
}
export function get_params() {
socket.emit('cmd', {
cmd: 'get_params',
})
}
export function set_param(key, value) {
socket.emit('cmd', {
cmd: 'set_param',
payload: {
'key': key,
'value': value,
}
})
}
export function run_system_command(cmd) {
socket.emit('system', {
cmd: 'run_system_command',
payload: cmd,
})
}
export { socket }
|