Skip to content

Commit 5000093

Browse files
committed
update call & publish examples
1 parent 109ad35 commit 5000093

3 files changed

Lines changed: 13 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {Session} from "xconn";
5151

5252

5353
async function examplePublish(session: Session) {
54-
await session.publish("io.xconn.example", {args: ["test"], kwargs: {"key": "value"}});
54+
await session.publish("io.xconn.example", ["test"], {"key": "value"});
5555
}
5656
```
5757

@@ -78,7 +78,7 @@ import {Session} from "xconn";
7878

7979

8080
async function exampleCall(session: Session) {
81-
await session.call("io.xconn.echo", {args: [1, 2], kwargs: {"key": "value"}});
81+
await session.call("io.xconn.echo", [1, 2], {"key": "value"});
8282
}
8383
```
8484

examples/pubsub/publisher.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@ async function main() {
88
await session.publish(testTopic);
99

1010
// publish event with args
11-
await session.publish(testTopic, {args: ["Hello", "World"]});
11+
await session.publish(testTopic, ["Hello", "World"]);
1212

1313
// publish event with kwargs
14-
await session.publish(testTopic, {kwargs: {"key": "value"}});
14+
await session.publish(testTopic, [], {"key": "value"});
1515

1616
// publish event with options
17-
await session.publish(testTopic, {options: {"acknowledge": true}});
17+
await session.publish(testTopic,[], {}, {"acknowledge": true});
1818

1919
// publish event with args & kwargs
20-
await session.publish(testTopic, {args: ["Hello", "World"], kwargs: {"key": "value"}});
20+
await session.publish(testTopic, ["Hello", "World"], {"key": "value"});
2121

2222
// publish event with args, kwargs & options
23-
await session.publish(testTopic, {
24-
args: ["Hello", "World"],
25-
kwargs: {"key": "value"},
26-
options: {"acknowledge": true}
27-
});
23+
await session.publish(testTopic, ["Hello", "World"], {"key": "value"}, {"acknowledge": true});
2824

2925
console.log(`Published events to ${testTopic}`);
3026

examples/rpc/caller.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,24 @@ async function main() {
88
const session = await connectAnonymous("ws://localhost:8080/ws", "realm1");
99

1010
// Call procedure "io.xconn.echo" with args and kwargs
11-
const result: Result = await session.call(testProcedureEcho, {
12-
args: ["hello", "world"],
13-
kwargs: {key: "value"},
14-
});
11+
const result: Result = await session.call(testProcedureEcho, ["hello", "world"], {key: "value"});
1512
console.log(`Result of procedure '${testProcedureEcho}': args=${result.args}, kwargs=${result.kwargs}`);
1613

1714
// Call with only args
18-
await session.call(testProcedureEcho, {args: ["hello", "world"]});
15+
await session.call(testProcedureEcho, ["hello", "world"]);
1916

2017
// Call with only kwargs
21-
await session.call(testProcedureEcho, {kwargs: {name: "john"}});
18+
await session.call(testProcedureEcho, [], {name: "john"});
2219

2320
// Call with both args and kwargs
24-
await session.call(testProcedureEcho, {args: [1, 2], kwargs: {name: "john"}});
21+
await session.call(testProcedureEcho, [1, 2], {name: "john"});
2522

2623
// Call procedure "io.xconn.async.echo" with args and kwargs
27-
const resultAsync: Result = await session.call(testProcedureAsyncEcho, {
28-
args: ["hello", "xconn"],
29-
kwargs: {key: "value"},
30-
});
24+
const resultAsync: Result = await session.call(testProcedureAsyncEcho, ["hello", "xconn"], {key: "value"});
3125
console.log(`Result of procedure '${testProcedureAsyncEcho}': args=${resultAsync.args}, kwargs=${resultAsync.kwargs}`);
3226

3327
// Call sum procedure and print result
34-
const sumResult: Result = await session.call(testProcedureSum, {args: [2, 2, 6]});
28+
const sumResult: Result = await session.call(testProcedureSum, [2, 2, 6]);
3529
console.log(`Sum=${sumResult.args?.[0]}`);
3630

3731
await session.close();

0 commit comments

Comments
 (0)