forked from CNXTEoEorg/remotebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.js
55 lines (46 loc) · 1.23 KB
/
state.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
const EventEmitter = require('events');
const statusKey = {
unknown: [
'no meeting',
"No meeting is in progress, I’m taking a nap!"
],
blue: [
'starting meeting',
"The meeting is ready to start, waiting for a remote nerd to confirm that the remote stream is up with `remotebot green`…"
],
green: [
'remote stream is up',
"The remote stream is working flawlessly!"
],
yellow: [
'pending questions',
"There are some questions from remote folks, try to answer them when you get to a good stopping point."
],
red: [
'remote stream is down',
"The remote stream has issues, pause the meeting until the problem is fixed."
]
};
const statuses = Object.keys(statusKey);
const defaultStatus = statuses[0];
class State extends EventEmitter {
constructor() {
super();
this.state = { status: defaultStatus };
}
getStatus() {
return this.state.status;
}
updateStatus(status) {
var state = this.state;
if (state.status !== status &&
statuses.indexOf(status) >= 0) {
state.status = status;
this.emit('change', this.state);
}
}
}
State.statusKey = statusKey;
State.statuses = statuses;
State.defaultStatus = defaultStatus;
module.exports = State;