You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/09/25 03:36:24 UTC
thrift git commit: THRIFT-4131: js / WebSocket / fix handling oneway
methods Client: js Patch: Martin Hejnfelt
Repository: thrift
Updated Branches:
refs/heads/master a17ef79e8 -> 48ba736a5
THRIFT-4131: js / WebSocket / fix handling oneway methods
Client: js
Patch: Martin Hejnfelt <mh...@newtec.dk>
This closes #1372
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/48ba736a
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/48ba736a
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/48ba736a
Branch: refs/heads/master
Commit: 48ba736a5800c0abc3b136ec478cf856f856ffcc
Parents: a17ef79
Author: James E. King, III <jk...@apache.org>
Authored: Sun Sep 24 08:46:27 2017 -0700
Committer: James E. King, III <jk...@apache.org>
Committed: Sun Sep 24 20:35:01 2017 -0700
----------------------------------------------------------------------
.../cpp/src/thrift/generate/t_js_generator.cc | 24 ++++++++++++--------
lib/js/src/thrift.js | 9 ++++++++
2 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/48ba736a/compiler/cpp/src/thrift/generate/t_js_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index 10b0ee1..c146da7 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -1510,16 +1510,20 @@ void t_js_generator::generate_service_client(t_service* tservice) {
f_service_ << indent() << "return this.output.getTransport().flush(callback);" << endl;
} else {
f_service_ << indent() << "if (callback) {" << endl;
- f_service_ << indent() << " var self = this;" << endl;
- f_service_ << indent() << " this.output.getTransport().flush(true, function() {" << endl;
- f_service_ << indent() << " var result = null;" << endl;
- f_service_ << indent() << " try {" << endl;
- f_service_ << indent() << " result = self.recv_" << funname << "();" << endl;
- f_service_ << indent() << " } catch (e) {" << endl;
- f_service_ << indent() << " result = e;" << endl;
- f_service_ << indent() << " }" << endl;
- f_service_ << indent() << " callback(result);" << endl;
- f_service_ << indent() << " });" << endl;
+ if((*f_iter)->is_oneway()) {
+ f_service_ << indent() << " this.output.getTransport().flush(true, null);" << endl;
+ } else {
+ f_service_ << indent() << " var self = this;" << endl;
+ f_service_ << indent() << " this.output.getTransport().flush(true, function() {" << endl;
+ f_service_ << indent() << " var result = null;" << endl;
+ f_service_ << indent() << " try {" << endl;
+ f_service_ << indent() << " result = self.recv_" << funname << "();" << endl;
+ f_service_ << indent() << " } catch (e) {" << endl;
+ f_service_ << indent() << " result = e;" << endl;
+ f_service_ << indent() << " }" << endl;
+ f_service_ << indent() << " callback(result);" << endl;
+ f_service_ << indent() << " });" << endl;
+ }
f_service_ << indent() << "} else {" << endl;
f_service_ << indent() << " return this.output.getTransport().flush();" << endl;
f_service_ << indent() << "}" << endl;
http://git-wip-us.apache.org/repos/asf/thrift/blob/48ba736a/lib/js/src/thrift.js
----------------------------------------------------------------------
diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index 37ba690..ab85e9d 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -575,6 +575,15 @@ Thrift.TWebSocketTransport.prototype = {
clientCallback();
};
}()));
+ if(callback) {
+ this.callbacks.push((function() {
+ var clientCallback = callback;
+ return function(msg) {
+ self.setRecvBuffer(msg);
+ clientCallback();
+ };
+ }()));
+ }
} else {
//Queue the send to go out __onOpen
this.send_pending.push({