forked from xxxsinx/bitburner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull.js
32 lines (25 loc) · 769 Bytes
/
pull.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
/** @param {NS} ns */
export async function main(ns) {
ns.disableLog('ALL');
const triggerPort = ns.getPortHandle(10);
const pullPort = ns.getPortHandle(20);
triggerPort.clear();
pullPort.clear();
let checksum = 0;
while (true) {
const start = performance.now();
// Send a command to the trigger
const command = checksum.toString();
//ns.tprint('WARN: Sending: ' + command);
triggerPort.write(command);
// Await a reply from the trigger
await pullPort.nextWrite();
const reply = pullPort.read();
const elapsed = performance.now() - start;
ns.print('WARN: Sent: + ' + checksum + ' Reply: ' + reply + ' elapsed: ' + elapsed.toFixed(3) + 'ms');
//ns.tprint('WARN: Waiting\n\n');
checksum++;
ns.print('');
await ns.sleep(250);
}
}