Skip to content

Commit dfbd5fb

Browse files
committed
Update
1 parent 70f6cf4 commit dfbd5fb

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gentle_rpc
22

3-
JSON-RPC 2.0 library with HTTP and WebSockets support for
3+
JSON-RPC 2.0 library (server and client) with HTTP and WebSockets support for
44
[deno](https://github.com/denoland/deno) and the browser.
55

66
## Server
@@ -10,7 +10,7 @@ JSON-RPC 2.0 library with HTTP and WebSockets support for
1010
Takes `Methods`, `ServerRequest` and `Options`.
1111

1212
```typescript
13-
import { serve } from "https://deno.land/std@0.97.0/http/server.ts"
13+
import { serve } from "https://deno.land/std@0.105.0/http/server.ts"
1414
import { respond } from "https://deno.land/x/gentle_rpc/mod.ts"
1515

1616
const server = serve("0.0.0.0:8000")
@@ -65,7 +65,7 @@ Takes a `Resource` for HTTP or a `WebSocket` for WebSockets and returns
6565
```typescript
6666
import { createRemote } from "https://deno.land/x/gentle_rpc/mod.ts"
6767
// Or import directly into the browser with:
68-
import { createRemote } from "https://cdn.jsdelivr.net/gh/timonson/gentle_rpc@v2.8/client/dist/remote.js"
68+
import { createRemote } from "https://cdn.jsdelivr.net/gh/timonson/gentle_rpc@v3.0/client/dist/remote.js"
6969

7070
// HTTP:
7171
const remote = createRemote("http://0.0.0.0:8000")
@@ -106,8 +106,8 @@ const notification = await remote.call("sayHello", ["World"], {
106106

107107
##### jwt
108108

109-
Adding a jwt to the optional property `jwt` will set the `Authorization` header
110-
to `` `Bearer ${jwt}` ``.
109+
Adding the option `{jwt: string}` will set the `Authorization` header to
110+
`` `Bearer ${jwt}` ``.
111111

112112
```typescript
113113
const user = await remote.call("login", undefined, { jwt })
@@ -163,16 +163,14 @@ const noise = await remote.call("callNamedParameters", {
163163
})
164164
// The result is: 200
165165

166-
const notification = await remote.call("sayHello", ["World"], true)
167-
// undefined
168-
169166
remote.socket.close()
170167
```
171168

172169
##### notification
173170

174171
```typescript
175-
const notification = await remote.animalsMakeNoise.notify(["wuufff"])
172+
const notification = await remote.call("animalsMakeNoise", ["wuufff"], true)
173+
// undefined
176174
```
177175

178176
##### messaging between multiple clients

examples/http/browser.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<body>
99
<h1>Hello World</h1>
1010
<script type="module">
11-
import { createRemote } from "https://cdn.jsdelivr.net/gh/timonson/gentle_rpc@v2.8/client/dist/http.js"
11+
import { createRemote } from "https://cdn.jsdelivr.net/gh/timonson/gentle_rpc@v3.0/client/dist/http.js"
1212
const remote = createRemote("http://127.0.0.1:8000")
13-
const greeting = await remote.sayHello(["World"])
14-
const namedParams = await remote.callNamedParameters({
13+
const greeting = await remote.call("sayHello", ["World"])
14+
const namedParams = await remote.call("callNamedParameters", {
1515
a: 5,
1616
b: 10,
1717
c: "result:",

examples/ws/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ const noise = await remote.call("callNamedParameters", {
1010
// The result is: 200
1111
console.log(noise);
1212

13+
const notification = await remote.call("animalsMakeNoise", ["wuufff"], true);
14+
// undefined
15+
console.log(notification);
16+
1317
remote.socket.close();

0 commit comments

Comments
 (0)