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