ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 1 | var thrift = require('thrift'); |
| 2 | var helloSvc = require('./gen-nodejs/HelloSvc.js'); |
| 3 | |
| 4 | var options = { |
| 5 | transport: thrift.TBufferedTransport, |
| 6 | protocol: thrift.TJSONProtocol, |
| 7 | path: "/hello", |
| 8 | headers: {"Connection": "close"}, |
| 9 | https: false |
| 10 | }; |
| 11 | |
| 12 | var connection = thrift.createHttpConnection("localhost", 9090, options); |
| 13 | var client = thrift.createHttpClient(helloSvc, connection); |
| 14 | |
| 15 | connection.on("error", function(err) { |
| 16 | console.log("Error: " + err); |
| 17 | }); |
| 18 | |
| 19 | client.hello_func(function(error, result) { |
| 20 | console.log("Msg from server: " + result); |
| 21 | }); |
| 22 | |
| 23 | |