-
Notifications
You must be signed in to change notification settings - Fork 0
/
Accounts6.lf
44 lines (39 loc) · 1.11 KB
/
Accounts6.lf
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
target C {
coordination: decentralized,
keepalive: true
}
import IntWebSocketServer from "lib/IntWebSocketServer.lf"
import AccountManager from "lib/AccountManager.lf"
reactor Server(hostport: int = 8080, initial_file: string = {= NULL =}, null_message_period: time = 1 s) {
input in: int
output received: int
timer t(0, null_message_period)
w = new IntWebSocketServer(hostport = hostport, initial_file = initial_file)
in -> w.response
reaction (w.received, t) -> received {=
if (w.received->is_present) {
lf_set(received, w.received->value);
} else {
// Send a null message.
lf_set(received, 0);
}
=}
}
federated reactor {
w1 = new Server(
hostport = 8080,
initial_file = {= LF_SOURCE_DIRECTORY LF_FILE_SEPARATOR "Bank1.html" =}
)
w2 = new Server(
hostport = 8081,
initial_file = {= LF_SOURCE_DIRECTORY LF_FILE_SEPARATOR "Bank2.html" =}
)
a1 = new AccountManager(STA = forever)
a2 = new AccountManager(STA = forever)
w1.received -> a1.in1
w2.received -> a2.in2
w1.received -> a2.in1
w2.received -> a1.in2
a1.out -> w1.in
a2.out -> w2.in
}