Browse Source

v 1.2.5 moar README

master
peter 4 years ago
parent
commit
f34ef48582
3 changed files with 7 additions and 5 deletions
  1. 4
    4
      README.md
  2. 1
    1
      package.json
  3. 2
    0
      test/Test.ts

+ 4
- 4
README.md View File

@@ -40,7 +40,7 @@ client.connect().then(async () => {
40 40
 
41 41
 rpclibrary offers a special type of call that can be used with callbacks. The callback **has to be the last argument** and **may be the only passed function**. 
42 42
 
43
-In order to function, some metadata has to be included in the return value of hooks. On success, the function is expected to return a `type SubscriptionResponse = { result: 'Success', uuid: string }` or in case of errors a `type ErrorResponse = { result: 'Error' }`.
43
+In order to function, some metadata has to be included in the return value of hooks. On success, the function is expected to return a `{ result: 'Success', uuid: string }` (Types.SubscriptionResponse) or in case of errors a `{ result: 'Error' }`(Types.ErrorResponse).
44 44
 
45 45
 The uuid, as the name implies, is used to uniquely identify the callback for a given invocation and also dictates the name given to the client-side RPC. Unless you got a preferred way of generating these (e.g. using some kind of unique information important to your task) we recommend [uuid](https://www.npmjs.com/package/uuid) for this purpose. 
46 46
 
@@ -58,9 +58,9 @@ const server = new Backend.RPCServer(port, [{
58 58
         {
59 59
             name: 'subscribe',
60 60
             hook: async (callback) => {
61
-                const resp:SubscriptionResponse = { result: 'Success', uuid: 'generate_a_random_string_here' } 
62
-                callbacks.set(resp.uuid, callback); 
63
-                return resp
61
+                const randStr = 'generate_a_random_string_here'
62
+                callbacks.set(randStr, callback); 
63
+                return { result: 'Success', uuid: randStr} 
64 64
             }
65 65
         },{
66 66
             name: 'unsubscribe',

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "rpclibrary",
3
-  "version": "1.2.4",
3
+  "version": "1.2.5",
4 4
   "description": "rpclibrary is a websocket on steroids!",
5 5
   "main": "./js/Index.js",
6 6
   "repository": {

+ 2
- 0
test/Test.ts View File

@@ -66,7 +66,9 @@ describe('RPCServer', () => {
66 66
     })
67 67
 
68 68
     it('should be able to use all kinds of RPC definitions', (done) => {
69
+        
69 70
         const echo = (x) => x
71
+        
70 72
         const server = new RPCServer(20003, [{
71 73
             name: 'HelloWorldRPCGroup',
72 74
             exportRPCs: ()  => [

Loading…
Cancel
Save