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
1010Takes ` 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"
1414import { respond } from " https://deno.land/x/gentle_rpc/mod.ts"
1515
1616const 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
6666import { 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:
7171const 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
113113const 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-
169166remote .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
0 commit comments