-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient.js
49 lines (43 loc) · 1.27 KB
/
client.js
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
var pyshell = require('python-shell');
var fs = require('fs');
let _uid = '';
let _pwd = '';
if (process.argv[2] == null) {
console.log("IP parameter can't empty");
process.exit();
}
var socket = require('socket.io-client')('http://' + process.argv[2] + ':8000');
socket.on('clientTest', function (data) {
console.log('data :', data);
});
socket.on('idToJetson', function (data) {
console.log('data: ', data);
let options = {
mode: 'text',
args: [data.id]
};
pyshell.PythonShell.run('../get_id_from_client_js.py', options, function (err, pythonResult) {
if (err) throw err;
});
_uid = data.uid;
_pwd = data.pwd;
});
function intervalFunc() {
try {
let content = fs.readFileSync('/home/gate/lffd-dir/msg_buffer.txt', 'utf8');
if (content != '') {
console.log(content);
socket.emit('faceRecogn', {
result: content,
uid: _uid,
pwd: _pwd
});
fs.writeFile('/home/gate/lffd-dir/msg_buffer.txt', '', function () {});
_uid = '';
_pwd = '';
}
} catch (e) {
console.log('Error:', e.stack);
}
}
setInterval(intervalFunc, 1000);