1.9.3 • Published 7 months ago

arpc v1.9.3

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

arpc

a node RPC library based on socket.io

examples

const server = require('arpc/server')(2333)
server.createService('test', {
    a: [() => {
        return 233
    }]
})
(async function(){
    const client = require('arpc/client')
    let obj = client('ws://127.0.0.1:2333', 'test')
    console.log(await obj.a[0]())
    //output: 233
})()

API

client require('arpc/client')

client(socketOrUrl, name, obj = null, path = '/rpc')

  • parameters
    • socketOrUrl: Socket | string
    • obj: any object for the calling from the server
    • path: string the path for socket.io (invalided if you passed a socket at the first parameter). this can be a secret token for rpc connection
  • return : Promise a object which can call the remote object with a prochain way (see examples)

server require('arpc/server')

server(ioOrPort, path = '/rpc')

  • parameters
    • ioOrPort: Server | number
    • path: string the same as the client api
  • return : RPC the rpc object

RPC require('arpc')

  • constructor new RPC()
  • metheds
    • connected(conn, name = 'server') call this when sockets connected
      • parameters
        • conn: Socket
        • name: string the service we request the other side
    • createService(name, obj, onConnect, onDisconnect)
      • name: string the name of the service we create
      • obj: any the object we provide for the remote calling
      • onConnected: (object: Promise) => undefined (optional) the function which will be called when a client connects
      • onDisconnect: (socket: Socket, reason: string) => undefined (optional) the function which will be called when a client disconnects
    • getServer(obj = null) creates a remote object from the server
      • paramaters
        • obj: any the object we provide for the remote calling
      • return : Promise the remote object from the server

license

MIT

1.8.1

7 months ago

1.8.0

7 months ago

1.9.3

7 months ago

1.9.2

7 months ago

1.9.1

7 months ago

1.9.0

7 months ago

1.7.0

7 months ago

1.6.11

7 months ago

1.6.10

7 months ago

1.6.13

7 months ago

1.6.12

7 months ago

1.6.15

7 months ago

1.6.14

7 months ago

1.6.17

7 months ago

1.6.16

7 months ago

1.6.18

7 months ago

1.6.9

7 months ago

1.6.8

7 months ago

1.6.7

7 months ago

1.6.4

9 months ago

1.6.3

9 months ago

1.6.2

9 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.6.5

9 months ago

1.4.6

10 months ago

1.5.2

10 months ago

1.5.1

10 months ago

1.5.0

10 months ago

1.4.9

10 months ago

1.4.11

10 months ago

1.4.8

10 months ago

1.4.10

10 months ago

1.4.7

10 months ago

1.4.12

10 months ago

1.3.7

10 months ago

1.4.5

10 months ago

1.3.6

10 months ago

1.4.4

10 months ago

1.3.5

10 months ago

1.4.3

10 months ago

1.3.4

10 months ago

1.4.2

10 months ago

1.3.3

10 months ago

1.4.1

10 months ago

1.3.2

10 months ago

1.4.0

10 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.3.8

10 months ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.0

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.0

4 years ago

0.0.4

4 years ago

1.0.0

4 years ago