Browse Source

v 1.2.4 minor README changes

master
peter 5 years ago
parent
commit
b9a8f06ec4
2 changed files with 8 additions and 8 deletions
  1. 7
    7
      README.md
  2. 1
    1
      package.json

+ 7
- 7
README.md View File

12
 
12
 
13
 const echo = (x) => x
13
 const echo = (x) => x
14
 
14
 
15
-const server = new Backend.RPCServer(20000, [{
15
+const server = new Backend.RPCServer(port, [{
16
     name: 'HelloWorldRPCGroup',
16
     name: 'HelloWorldRPCGroup',
17
     exportRPCs: ()  => [
17
     exportRPCs: ()  => [
18
         echo, //named function variable
18
         echo, //named function variable
24
     ]
24
     ]
25
 }])
25
 }])
26
 
26
 
27
-const client = new Frontend.RPCSocket(20000, 'localhost')
27
+const client = new Frontend.RPCSocket(port, host)
28
 
28
 
29
 client.connect().then(async () => {
29
 client.connect().then(async () => {
30
     const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
30
     const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
51
 
51
 
52
 const callbacks:Map<string, Function> = new Map()
52
 const callbacks:Map<string, Function> = new Map()
53
 
53
 
54
-const server = new Backend.RPCServer(20000, [{
54
+const server = new Backend.RPCServer(port, [{
55
     name: 'HelloWorldRPCGroup',
55
     name: 'HelloWorldRPCGroup',
56
     exportRPCs: ()  => [
56
     exportRPCs: ()  => [
57
         function  triggerCallbacks(...messages){ callbacks.forEach(cb => cb.apply({}, messages)) },
57
         function  triggerCallbacks(...messages){ callbacks.forEach(cb => cb.apply({}, messages)) },
69
     ]
69
     ]
70
 }])
70
 }])
71
 
71
 
72
-const client = new Frontend.RPCSocket(20000, 'localhost')
72
+const client = new Frontend.RPCSocket(port, host)
73
 client.connect().then(async () => {
73
 client.connect().then(async () => {
74
     const res = await client['HelloWorldRPCGroup'].subscribe(async (...args:any) => {
74
     const res = await client['HelloWorldRPCGroup'].subscribe(async (...args:any) => {
75
         console.log.apply(console, args)
75
         console.log.apply(console, args)
86
 If you need to include further response data into your `SubscriptionResponse` you can extend it using the server's first generic parameter `SubResType`
86
 If you need to include further response data into your `SubscriptionResponse` you can extend it using the server's first generic parameter `SubResType`
87
 
87
 
88
 ```typescript
88
 ```typescript
89
-new RPCServer<{extension: string}>({
89
+new RPCServer<{extension: string}>(port, {
90
     name: 'MyRPCGroup',
90
     name: 'MyRPCGroup',
91
     exportRPCs: ()  => [{
91
     exportRPCs: ()  => [{
92
         name: 'subscribe',
92
         name: 'subscribe',
126
 
126
 
127
 /* OR */
127
 /* OR */
128
 
128
 
129
-const client = new Frontend.RPCSocket(20000, 'localhost')
129
+const client = new Frontend.RPCSocket(port, host)
130
 client.connect<MyInterface>().then((async (client) => {
130
 client.connect<MyInterface>().then((async (client) => {
131
     const r = await client.Group2.echo("hee") //tsc knows about available RPCs 
131
     const r = await client.Group2.echo("hee") //tsc knows about available RPCs 
132
 })) 
132
 })) 
134
 
134
 
135
 Create a server using
135
 Create a server using
136
 ```typescript
136
 ```typescript
137
-new RPCServer<{a:string}, MyInterface>(20001, 
137
+new RPCServer<{a:string}, MyInterface>(port, 
138
     [{
138
     [{
139
         //...
139
         //...
140
     },{
140
     },{

+ 1
- 1
package.json View File

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

Loading…
Cancel
Save