Created
June 12, 2017 08:17
-
-
Save jiangzhuo/98d97705064d7bbc5257d81bc59cde47 to your computer and use it in GitHub Desktop.
hprose-nodejs-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hprose = require("./lib/hprose"); | |
var client = hprose.Client.create("http://127.0.0.1:8080/"); | |
var proxy = client.useService(); | |
// console.log(proxy.hello) | |
// console.log(proxy.a.hello) | |
proxy.hello("world", function(result) { | |
console.log(result); | |
}, function(name, err) { | |
console.error(err); | |
}); | |
var a = proxy.a.hello("shit", function(result) { | |
console.log(result); | |
}, function(name, err) { | |
console.error(err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hprose = require("./lib/hprose"); | |
function hello(name) { | |
return "Hello " + name + "!"; | |
} | |
var a = { | |
hello: function hello(name) { | |
return "Hello " + name + "!"; | |
} | |
} | |
var server = hprose.Server.create("http://0.0.0.0:8080"); | |
server.addFunction(hello); | |
server.addInstanceMethods(a,'a'); | |
server.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment