-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomms.ks
41 lines (31 loc) · 1.13 KB
/
comms.ks
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
function test_comms {
parameter connection.
parameter messages.
print connection:delay = 0.
print connection:isconnected.
messages:clear.
print messages:empty.
set m to lex("key1", 1, "key2", "value2", true, ship).
print connection:sendmessage(m).
print not messages:empty.
set received to messages:pop.
print messages:empty.
print received:sender = ship.
print received:content:typename = "Lexicon".
print received:content[true] = ship.
print connection:sendmessage(4).
set received to messages:pop.
print received:content = 4.
print connection:sendmessage(true).
set received to messages:pop.
print received:content = true.
print connection:sendmessage("testmessage").
set received to messages:pop.
print received:content = "testmessage".
}
// Inter-vessel tests, this doesn't do any long-range tests, vessel simply sends messages to itself
print ship:connection:tostring:contains(ship:name).
test_comms(ship:connection, ship:messages).
// Inter-CPU tests, as before the cpu sends messages to itself
print core:connection:tostring:contains(core:tag).
test_comms(core:connection, core:messages).