forked from UTCSheffield/lean_manufacturing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
socket.js
70 lines (59 loc) · 1.55 KB
/
socket.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module.exports = function(io) {
var oLean = {
aLines:[],
refresh: function(){
//if still looking for vicitims
if(this.aLines.length === 0) {
return {
emit: 'Available Roles',
resp:this.respAvailableRoles()
};
}
},
respAvailableRoles: function(){
var aResp = {
message: "Select Role for this device",
buttons: []
};
if(this.aLines.length === 0) {
aResp.buttons.push({
label: "Line 1 : Manager",
display:"green",
emit: "Become Manager",
emit_data: JSON.stringify({line: 0})
});
} else {
}
return aResp;
}
/*,
getAvailableRoles: function(){
if(this.aLines.length === 0) {
return [
{
label:"Line 1 : Manager",
line:1,
role:"Manager",
cellid:0
}
];
} else {
return [];
}
}*/
};
io.on('connection', function (socket) {
var oLeanSocket = io.of('/lean-game');
oLeanSocket.on('connection', function(socket){
socket.emit('Available Roles', oLean.respAvailableRoles());
socket.on('Refresh', function (data) {
console.log(data);
var oRefreshAction = oLean.Refresh();
socket.emit(oRefreshAction.emit, oRefreshAction.resp);
});
socket.on('Become Manager', function (data) {
console.log("Become Manager", data);
});
});
});
};