# fingerprint-container-node-sdk2

> fingerprint container's sdk

Latest version **0.0.7** (published 2017-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install fingerprint-container-node-sdk2
pnpm add fingerprint-container-node-sdk2
yarn add fingerprint-container-node-sdk2
bun add fingerprint-container-node-sdk2
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2017-09-13 |
| First published | 2017-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | peng19956 |
| Maintainers | fredyxue, peng19956 |
| Keywords | fingerprint |

## Links

- npm: https://www.npmjs.com/package/fingerprint-container-node-sdk2
- Repository: git@git.quanmin.tv:penganhua/fingerprint-container-node-sdk2
- npm.io page: https://npm.io/package/fingerprint-container-node-sdk2

## Dependencies (5)

- [getmac](https://npm.io/package/getmac.md) ^1.2.1
- [thenjs](https://npm.io/package/thenjs.md) ^2.0.5
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^3.0.1
- [buffer-crc32](https://npm.io/package/buffer-crc32.md) ^0.2.13

## Recent versions

- 0.0.7 (latest) — 2017-09-13
- 0.0.6 — 2017-09-12
- 0.0.5 — 2017-09-12
- 0.0.4 — 2017-09-12
- 0.0.3 — 2017-09-12
- 0.0.2 — 2017-09-12
- 0.0.1 — 2017-09-11

## README

FPC NODE SDK
------------
## Run Unit Test
```shell
npm install && npm test
```

## Server API

```javascript
    var FPC = require('fingerprint-container-node-sdk2');
    var server = new FPC.Server('127.0.0.1','9090');
    
    // 增加一个rpc handler
    server.addHandler('ServiceName',function(res){
        //回复调用的client
        res.send({
            words: "hello world!"
        });

        server.destroy();
    });
    
    // 监听connect事件
    server.on('connect',function(){
        // connect成功后进行服务注册
        server.register();
    });
       
    // 注册成功回调
    server.on('register',function(){
        console.log('register success');
    });
```


## Client API

```javascript
    var FPC = require('fingerprint-container-node-sdk2');
    var client = new FPC.Client('127.0.0.1','9090');
    
    // 监听connect事件
    client.on('connect',function(){
        // connect成功后进行服务注册
        client.register();
    });
    
    // 注册成功回调
    client.on('register',function(){
        // 发送一个event事件给容器
        client.eventRequest('ServiceName', {
            name: 'event'
        });
        
        // 发送一个rpc给容器，timeout=2s, 等待server回复
        client.rpcRequest('ServiceName',{
            name: 'rpc'
        },function(body){
            console.log(body);
            client.destroy(); // 销毁client
        }, function(){
            console.log("timeout");
        },2000);
    });
```

#ClientPool API

```javascript
    var FPC = require('fingerprint-container-node-sdk2');
    var pool = new FPC.ClientPool({
        host: '127.0.0.1',
        port: 8080,
        num: 5, // 启动多少client，默认为5
        name: 'mis', // Server名
        heartbeat: 30*1000 // 心跳检测轮询时间，用来剔除失活的链接
    });

    pool.acquire(function(client){
        client.rpcRequest('ServiceName',{
            name: 'rpc'
        },function(body){
            pool.release(client);
            console.log(body);
        }, function(){
            pool.release(client);
            console.log("timeout");
        },2000);
    });
```

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