Skip to content

Hello World

小马哥 edited this page Aug 9, 2015 · 4 revisions

首先让我们从 Hello World 开始。

服务器

var hprose = require("hprose");
function hello(name) {
    return "Hello " + name + "!";
}
var server = hprose.Server.create("http://0.0.0.0:8080");
server.addFunction(hello);
server.start();

启动服务器:

node server.js

客户端

var hprose = require("hprose");
var client = hprose.Client.create("http://127.0.0.1:8080/", ['hello']);
client.hello("world", function(result) {
    console.log(result);
});

启动客户端:

node client.js
Clone this wiki locally