基于NodeJs的JSON協議的RPC解決方案 DNode
DNode:一個非常不錯的基于NodeJs的JSON協議的RPC遠程調用解決方案,并且還可以實現瀏覽器端直接調用遠程服務(通過基于socket.io的websocket開發庫)
安裝方法:npm install dnode
示例代碼:
var dnode = require('dnode'); dnode.connect(5050, function (remote) { remote.zing(66, function (n) { console.log('n = ' + n); }); });
var express = require('express'); var app = express.createServer(); app.use(express.static(__dirname)); app.listen(8080); console.log('http://localhost:8080/'); // then just pass the server app handle to .listen()! var dnode = require('dnode'); var server = dnode({ zing : function (n, cb) { cb(n * 100) } }); server.listen(app);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!