v 1.2.4 minor README changes
This commit is contained in:
@@ -12,7 +12,7 @@ import {Backend, Frontend} from 'rpclibrary'
|
|||||||
|
|
||||||
const echo = (x) => x
|
const echo = (x) => x
|
||||||
|
|
||||||
const server = new Backend.RPCServer(20000, [{
|
const server = new Backend.RPCServer(port, [{
|
||||||
name: 'HelloWorldRPCGroup',
|
name: 'HelloWorldRPCGroup',
|
||||||
exportRPCs: () => [
|
exportRPCs: () => [
|
||||||
echo, //named function variable
|
echo, //named function variable
|
||||||
@@ -24,7 +24,7 @@ const server = new Backend.RPCServer(20000, [{
|
|||||||
]
|
]
|
||||||
}])
|
}])
|
||||||
|
|
||||||
const client = new Frontend.RPCSocket(20000, 'localhost')
|
const client = new Frontend.RPCSocket(port, host)
|
||||||
|
|
||||||
client.connect().then(async () => {
|
client.connect().then(async () => {
|
||||||
const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
|
const r0 = await client['HelloWorldRPCGroup'].echo('Hello')
|
||||||
@@ -51,7 +51,7 @@ import {Backend, Frontend, Utils} from 'rpclibrary'
|
|||||||
|
|
||||||
const callbacks:Map<string, Function> = new Map()
|
const callbacks:Map<string, Function> = new Map()
|
||||||
|
|
||||||
const server = new Backend.RPCServer(20000, [{
|
const server = new Backend.RPCServer(port, [{
|
||||||
name: 'HelloWorldRPCGroup',
|
name: 'HelloWorldRPCGroup',
|
||||||
exportRPCs: () => [
|
exportRPCs: () => [
|
||||||
function triggerCallbacks(...messages){ callbacks.forEach(cb => cb.apply({}, messages)) },
|
function triggerCallbacks(...messages){ callbacks.forEach(cb => cb.apply({}, messages)) },
|
||||||
@@ -69,7 +69,7 @@ const server = new Backend.RPCServer(20000, [{
|
|||||||
]
|
]
|
||||||
}])
|
}])
|
||||||
|
|
||||||
const client = new Frontend.RPCSocket(20000, 'localhost')
|
const client = new Frontend.RPCSocket(port, host)
|
||||||
client.connect().then(async () => {
|
client.connect().then(async () => {
|
||||||
const res = await client['HelloWorldRPCGroup'].subscribe(async (...args:any) => {
|
const res = await client['HelloWorldRPCGroup'].subscribe(async (...args:any) => {
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
@@ -86,7 +86,7 @@ client.connect().then(async () => {
|
|||||||
If you need to include further response data into your `SubscriptionResponse` you can extend it using the server's first generic parameter `SubResType`
|
If you need to include further response data into your `SubscriptionResponse` you can extend it using the server's first generic parameter `SubResType`
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
new RPCServer<{extension: string}>({
|
new RPCServer<{extension: string}>(port, {
|
||||||
name: 'MyRPCGroup',
|
name: 'MyRPCGroup',
|
||||||
exportRPCs: () => [{
|
exportRPCs: () => [{
|
||||||
name: 'subscribe',
|
name: 'subscribe',
|
||||||
@@ -126,7 +126,7 @@ RPCSocket.makeSocket<MyInterface>(port, host).then((async (client) => {
|
|||||||
|
|
||||||
/* OR */
|
/* OR */
|
||||||
|
|
||||||
const client = new Frontend.RPCSocket(20000, 'localhost')
|
const client = new Frontend.RPCSocket(port, host)
|
||||||
client.connect<MyInterface>().then((async (client) => {
|
client.connect<MyInterface>().then((async (client) => {
|
||||||
const r = await client.Group2.echo("hee") //tsc knows about available RPCs
|
const r = await client.Group2.echo("hee") //tsc knows about available RPCs
|
||||||
}))
|
}))
|
||||||
@@ -134,7 +134,7 @@ client.connect<MyInterface>().then((async (client) => {
|
|||||||
|
|
||||||
Create a server using
|
Create a server using
|
||||||
```typescript
|
```typescript
|
||||||
new RPCServer<{a:string}, MyInterface>(20001,
|
new RPCServer<{a:string}, MyInterface>(port,
|
||||||
[{
|
[{
|
||||||
//...
|
//...
|
||||||
},{
|
},{
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rpclibrary",
|
"name": "rpclibrary",
|
||||||
"version": "1.2.3",
|
"version": "1.2.4",
|
||||||
"description": "rpclibrary is a websocket on steroids!",
|
"description": "rpclibrary is a websocket on steroids!",
|
||||||
"main": "./js/Index.js",
|
"main": "./js/Index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user