From 501cc67fcedc381d6573fd0985bece3a1edab5c7 Mon Sep 17 00:00:00 2001 From: sidorares Date: Tue, 2 Aug 2011 15:22:09 +1000 Subject: [PATCH] store function instead of request name (extensions!!!) --- lib/x11/xcore.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/x11/xcore.js b/lib/x11/xcore.js index 4a2ace1..ce1077d 100644 --- a/lib/x11/xcore.js +++ b/lib/x11/xcore.js @@ -124,7 +124,7 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs) var requestArguments = reqPack[1]; if (callback) - this.replies[this.seq_num] = [reqName, callback]; + this.replies[this.seq_num] = [reqReplTemplate[1], callback]; client.pack_stream.pack(format, requestArguments); var b = client.pack_stream.write_queue[0]; @@ -140,9 +140,8 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs) requestArguments.push(args[a]); if (callback) - this.replies[this.seq_num] = [reqName, callback]; + this.replies[this.seq_num] = [reqReplTemplate[1], callback]; - //console.log([format, requestArguments]); client.pack_stream.pack(format, requestArguments); client.pack_stream.flush(); } else { @@ -214,6 +213,7 @@ XClient.prototype.expectReplyHeader = function() 'CCSL', function(res) { var type = res[0]; var seq_num = res[2]; + if (type == 0) { var error_code = res[1]; @@ -233,7 +233,6 @@ XClient.prototype.expectReplyHeader = function() error.minorOpcode = res[1]; error.majorOpcode = res[2]; } - //console.log(error); var handler = client.replies[seq_num]; if (handler) { var callback = handler[1]; @@ -268,12 +267,11 @@ XClient.prototype.expectReplyHeader = function() var handler = client.replies[seq_num]; if (handler) { - var reqName = handler[0]; - var req = coreRequests[reqName]; - var unpack = req[1]; + var unpack = handler[0]; var result = unpack( data, opt_data ); var callback = handler[1]; callback(result); + // TODO: add multiple replies flag and delete handler only after last reply (eg ListFontsWithInfo) delete client.replies[seq_num]; } // wait for new packet from server