瀏覽代碼

push

master
peter 5 年之前
父節點
當前提交
ed3da909c6
共有 1 個檔案被更改,包括 32 行新增0 行删除
  1. 32
    0
      README.md

+ 32
- 0
README.md 查看文件

@@ -1,8 +1,40 @@
1 1
 # About
2
+rpclibrary is a websocket on steroids!
2 3
 
3 4
 # How to install
5
+```
6
+npm i rpclibrary
7
+```
4 8
 
5 9
 # Quickstart
10
+```typescript
11
+import {Backend, Frontend} from 'rpclibrary'
12
+
13
+const echo = (x) => x
14
+
15
+const server = new Backend.RPCServer(20000, [{
16
+    name: 'HelloWorldRPCGroup',
17
+    exportRPCs: ()  => [
18
+        echo,
19
+        function echof(x){ return x },
20
+        {
21
+            name: 'echoExplicit',
22
+            call: async (x) => x
23
+        }
24
+    ]
25
+}])
26
+
27
+const client = new Frontend.RPCSocket(20000, 'localhost')
28
+
29
+client.connect().then(async () => {
30
+    const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
31
+    const r1 = await client['HelloWorldRPCGroup'].echof('World')
32
+    const r2 = await client['HelloWorldRPCGroup'].echoExplicit('RPC!')
33
+
34
+    console.log(r0,r1,r2)
35
+})
36
+
37
+```
6 38
 
7 39
 # Documentation
8 40
 [https://gitea.frontblock.me/fw-docs/rpclibrary]

Loading…
取消
儲存