Browse Source

push

master
peter 4 years ago
parent
commit
ed3da909c6
1 changed files with 32 additions and 0 deletions
  1. 32
    0
      README.md

+ 32
- 0
README.md View File

@@ -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…
Cancel
Save