Node.js Fast
- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://www.npmjs.org/package/fast
- 软件文档: https://github.com/mcavage/node-fast
软件介绍
Fast 是 Node.js 的一个很小的基于 TCP 消息框架的 JSON 远程调用包,可用来编写简单的基于 JSON 的 RPC 系统。
示例代码:
var fast = require('fast');
var server = fast.createServer();
server.rpc('echo', function (fname, lname, res) {
res.write({first: fname});
res.end({last: lname});
});
server.listen(1234);
/// Client
var client = fast.createClient({host: 'localhost', port: 1234});
client.on('connect', function () {
var req = client.rpc('echo', 'mark', 'cavage');
req.on('message', function (obj) {
console.log(JSON.stringify(obj, null, 2));
});
req.on('end', function () {
client.close();
server.close();
});
});
