-
Notifications
You must be signed in to change notification settings - Fork 5
/
direct-callback.mjs
40 lines (35 loc) · 990 Bytes
/
direct-callback.mjs
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
import { Client, sapnwrfcEvents } from "node-rfc";
// parse command line arguments to numbers
const [WAIT, TIMEOUT] = process.argv.slice(2).map((e) => {
return Number(e);
});
sapnwrfcEvents.on("sapnwrfc:clientCancel", (data) =>
console.log("event", data)
);
// event { id: 1, connectionHandle: 140576595093504
const client = new Client({ dest: "MME" }, { timeout: TIMEOUT });
client.open((err) => {
if (err) return console.error(err);
client.invoke(
"RFC_PING_AND_WAIT",
{
SECONDS: WAIT,
},
(err, res) => {
if (err) {
console.error("err", err, client.alive, client.connectionHandle);
// {
// name: 'RfcLibError',
// group: 4,
// code: 7,
// codeString: 'RFC_CANCELED',
// key: 'RFC_CANCELED',
// message: 'Connection was canceled.'
// }
} else {
console.log("done", res);
}
}
// { timeout: TIMEOUT } // overrides client timeout
);
});