forked from NexusNull/bot-web-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.js
47 lines (39 loc) · 1008 Bytes
/
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
/**
* Created by Nexus on 01.08.2017.
*/
let i = 0;
class Client {
constructor(socket) {
this.socket = socket;
this.id = i++;
this.setupSend = false;
}
sendSetup(structure, dataList) {
const res = {
dataCache: dataList,
structure: structure,
};
this.socket.emit("setup", res);
this.setupSend = true;
}
sendUpdate(dataList) {
if (!this.setupSend)
return;
this.socket.emit("updateBotUI", dataList);
};
pushData(id, name, value) {
if (!this.setupSend)
return;
var data = {id: id, name: name, value: value};
this.socket.emit("updateProperty", data);
};
removeInterface(ids) {
this.socket.emit("removeBotUI", ids);
};
createInterface(botUI) {
var structure = botUI.getStructure();
structure.id = botUI.id;
this.socket.emit("createBotUI", structure);
};
}
module.exports = Client;