THRIFT-2398:Improve Node Server Library\nClient: Node\nPatch: Randy Abernethy\n\nGeneral server parameter harmonization and comments
diff --git a/lib/nodejs/test/multiplex_server.js b/lib/nodejs/test/multiplex_server.js
index a2ea535..6331f6f 100644
--- a/lib/nodejs/test/multiplex_server.js
+++ b/lib/nodejs/test/multiplex_server.js
@@ -17,9 +17,6 @@
* under the License.
*/
var thrift = require('thrift');
-var Thrift = thrift.Thrift;
-var ThriftTransports = require('thrift/transport');
-var ThriftProtocols = require('thrift/protocol');
var ThriftTest = require('./gen-nodejs/ThriftTest'),
SecondService = require('./gen-nodejs/SecondService'),
@@ -36,25 +33,14 @@
.option('--ssl', 'use ssl transport')
.parse(process.argv);
-var protocol = undefined;
-var transport = undefined;
-
-if (program.protocol === "binary") {
- protocol = ThriftProtocols.TBinaryProtocol;
-} else if (program.protocol === "json") {
- protocol = ThriftProtocols.TJSONProtocol;
-} else {
- //default
- protocol = ThriftProtocols.TBinaryProtocol;
+var protocol = thrift.TBinaryProtocol;
+if (program.protocol === "json") {
+ protocol = thrift.TJSONProtocol;
}
+var transport = thrift.TBufferedTransport;
if (program.transport === "framed") {
- transport = ThriftTransports.TFramedTransport;
-} else if (program.transport === "buffered") {
- transport = ThriftTransports.TBufferedTransport;
-} else {
- //default
- transport = ThriftTransports.TBufferedTransport;
+ transport = thrift.TFramedTransport;
}
var ThriftTestHandler = require("./test_handler").ThriftTestHandler;
@@ -81,14 +67,12 @@
protocol: protocol
};
-var server = undefined;
if (program.ssl) {
//ssl options
- options.key = fs.readFileSync(path.resolve(__dirname, 'server.key'));
- options.cert = fs.readFileSync(path.resolve(__dirname, 'server.crt'));
- server = thrift.createMultiplexSSLServer(processor, options);
-} else {
- server = thrift.createMultiplexServer(processor, options);
+ options.tls = {
+ key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
+ cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))
+ }
}
-server.listen(9090);
+thrift.createMultiplexServer(processor, options).listen(9090);