# rpc.io

> rpc over socket.io

Latest version **1.1.1** (published 2016-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install rpc.io
pnpm add rpc.io
yarn add rpc.io
bun add rpc.io
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-02-05 |
| First published | 2014-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zf |
| Maintainers | zf |
| Keywords | rpc, socket.io, websocket |

## Links

- npm: https://www.npmjs.com/package/rpc.io
- Repository: https://github.com/zweifisch/rpc.io
- Issues: https://github.com/zweifisch/rpc.io/issues
- npm.io page: https://npm.io/package/rpc.io

## Dependencies (2)

- [evocatio](https://npm.io/package/evocatio.md) 0.0.2
- [serialize-error](https://npm.io/package/serialize-error.md) ^1.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-02-05
- 1.1.0 — 2016-02-03
- 1.0.1 — 2016-02-02
- 1.0.0 — 2016-02-02
- 0.0.3 — 2016-01-21
- 0.0.2 — 2015-04-14
- 0.0.1 — 2014-06-15
- 0.0.0 — 2014-06-15

## README

# rpc.io

[![NPM Version][npm-image]][npm-url]

rpc over socket.io

## usage

clientside:

```javascript
let rpc = require('rpc.io-client')(socket, 2000);  # timeout

rpc.call('users.get', {id: 1024}) # Promise
```

serverside:

```javascript
io.on('connection', (socket)=> {

    rpc = require("rpc.io")(socket);

    rpc.register('users.get', (id)=> {nickname: 'foo'});

    rpc.register('users', {
        delete: function*(id) {
            yield db.items.remove({owner: id});
            db.users.remove({_id: id});
        }
    });
});
```

### optional params

```javascript
rpc.register('projects.create', {description: ''}, (name, description)=>);
```

```javascript
socket.register('projects', {
    create_defaults: {
        description: ''
    },
    create: (name, description)=>
});
```

### handle all rpc calls

```javascript
rpc.on("call", (method, kwargs)=> throw Error `method ${method} not implemented`);
```

### handle errors

```javascript
rpc.on("error", (method, kwargs, error)=> log.error(error));
```

[npm-image]: https://img.shields.io/npm/v/rpc.io.svg?style=flat
[npm-url]: https://npmjs.org/package/rpc.io

---
_Source: https://npm.io/package/rpc.io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
