diff options
Diffstat (limited to 'js/src/Ice/IncomingAsync.js')
-rw-r--r-- | js/src/Ice/IncomingAsync.js | 146 |
1 files changed, 78 insertions, 68 deletions
diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js index 619ffd70892..30453faabc3 100644 --- a/js/src/Ice/IncomingAsync.js +++ b/js/src/Ice/IncomingAsync.js @@ -7,10 +7,9 @@ // // ********************************************************************** -var Ice = require("../Ice/ModuleRegistry").Ice; +const Ice = require("../Ice/ModuleRegistry").Ice; Ice.__M.require(module, [ - "../Ice/Class", "../Ice/Stream", "../Ice/BuiltinSequences", "../Ice/Connection", @@ -24,17 +23,18 @@ Ice.__M.require(module, "../Ice/StringUtil" ]); -var OutputStream = Ice.OutputStream; -var Current = Ice.Current; -var Debug = Ice.Debug; -var FormatType = Ice.FormatType; -var Context = Ice.Context; -var Identity = Ice.Identity; -var Protocol = Ice.Protocol; -var StringUtil = Ice.StringUtil; - -var IncomingAsync = Ice.Class({ - __init__: function(instance, connection, adapter, response, compress, requestId) +const OutputStream = Ice.OutputStream; +const Current = Ice.Current; +const Debug = Ice.Debug; +const FormatType = Ice.FormatType; +const Context = Ice.Context; +const Identity = Ice.Identity; +const Protocol = Ice.Protocol; +const StringUtil = Ice.StringUtil; + +class IncomingAsync +{ + constructor(instance, connection, adapter, response, compress, requestId) { this._instance = instance; this._response = response; @@ -72,8 +72,9 @@ var IncomingAsync = Ice.Class({ this._cb = null; this._active = true; - }, - __startWriteParams: function(format) + } + + __startWriteParams(format) { if(!this._response) { @@ -85,19 +86,21 @@ var IncomingAsync = Ice.Class({ this._os.writeByte(0); this._os.startEncapsulation(this._current.encoding, format); return this._os; - }, - __endWriteParams: function(ok) + } + + __endWriteParams(ok) { if(this._response) { - var save = this._os.pos; + const save = this._os.pos; this._os.pos = Protocol.headerSize + 4; // Reply status position. this._os.writeByte(ok ? Protocol.replyOK : Protocol.replyUserException); this._os.pos = save; this._os.endEncapsulation(); } - }, - __writeEmptyParams: function() + } + + __writeEmptyParams() { if(this._response) { @@ -106,8 +109,9 @@ var IncomingAsync = Ice.Class({ this._os.writeByte(Protocol.replyOK); this._os.writeEmptyEncapsulation(this._current.encoding); } - }, - __writeParamEncaps: function(v, ok) + } + + __writeParamEncaps(v, ok) { if(this._response) { @@ -123,25 +127,27 @@ var IncomingAsync = Ice.Class({ this._os.writeEncapsulation(v); } } - }, - __writeUserException: function(ex, format) + } + + __writeUserException(ex, format) { - var os = this.__startWriteParams(format); + const os = this.__startWriteParams(format); os.writeUserException(ex); this.__endWriteParams(false); - }, - __warning: function(ex) + } + + __warning(ex) { Debug.assert(this._instance !== null); - var s = []; + const s = []; s.push("dispatch exception:"); s.push("\nidentity: " + Ice.identityToString(this._current.id)); s.push("\nfacet: " + StringUtil.escapeString(this._current.facet, "")); s.push("\noperation: " + this._current.operation); if(this._connection !== null) { - for(var p = this._connection.getInfo(); p; p = p.underlying) + for(let p = this._connection.getInfo(); p; p = p.underlying) { if(p instanceof Ice.IPConnectionInfo) { @@ -155,8 +161,9 @@ var IncomingAsync = Ice.Class({ s.push(ex.stack); } this._instance.initializationData().logger.warning(s.join("")); - }, - __servantLocatorFinished: function() + } + + __servantLocatorFinished() { Debug.assert(this._locator !== null && this._servant !== null); try @@ -195,13 +202,13 @@ var IncomingAsync = Ice.Class({ } return false; } - }, - __handleException: function(ex) + } + + __handleException(ex) { Debug.assert(this._connection !== null); - var props = this._instance.initializationData().properties; - var s; + const props = this._instance.initializationData().properties; if(ex instanceof Ice.RequestFailedException) { if(ex.id === null) @@ -335,7 +342,7 @@ var IncomingAsync = Ice.Class({ this._os.resize(Protocol.headerSize + 4); // Reply status position. this._os.writeByte(Protocol.replyUnknownLocalException); //this._os.writeString(ex.toString()); - s = [ ex.ice_name() ]; + let s = [ ex.ice_name() ]; if(ex.stack) { s.push("\n"); @@ -361,7 +368,7 @@ var IncomingAsync = Ice.Class({ this._os.resize(Protocol.headerSize + 4); // Reply status position. this._os.writeByte(Protocol.replyUnknownUserException); //this._os.writeString(ex.toString()); - s = [ ex.ice_name() ]; + let s = [ ex.ice_name() ]; if(ex.stack) { s.push("\n"); @@ -397,13 +404,12 @@ var IncomingAsync = Ice.Class({ } this._connection = null; - }, - invoke: function(servantManager, stream) + } + + invoke(servantManager, stream) { this._is = stream; - var start = this._is.pos; - // // Read the current. // @@ -412,7 +418,7 @@ var IncomingAsync = Ice.Class({ // // For compatibility with the old FacetPath. // - var facetPath = Ice.StringSeqHelper.read(this._is); + const facetPath = Ice.StringSeqHelper.read(this._is); if(facetPath.length > 0) { if(facetPath.length > 1) @@ -429,12 +435,10 @@ var IncomingAsync = Ice.Class({ this._current.operation = this._is.readString(); this._current.mode = Ice.OperationMode.valueOf(this._is.readByte()); this._current.ctx = new Context(); - var sz = this._is.readSize(); + let sz = this._is.readSize(); while(sz-- > 0) { - var first = this._is.readString(); - var second = this._is.readString(); - this._current.ctx.set(first, second); + this._current.ctx.set(this._is.readString(), this._is.readString()); } // @@ -442,7 +446,6 @@ var IncomingAsync = Ice.Class({ // in the code above are considered fatal, and must propagate to // the caller of this operation. // - if(servantManager !== null) { this._servant = servantManager.findServant(this._current.id, this._current.facet); @@ -464,8 +467,7 @@ var IncomingAsync = Ice.Class({ { if(ex instanceof Ice.UserException) { - var encoding = this._is.skipEncapsulation(); // Required for batch requests. - + const encoding = this._is.skipEncapsulation(); // Required for batch requests. if(this._response) { this._os.writeByte(Protocol.replyUserException); @@ -525,12 +527,12 @@ var IncomingAsync = Ice.Class({ if(servantManager !== null && servantManager.hasServant(this._current.id)) { throw new Ice.FacetNotExistException(this._current.id, this._current.facet, - this._current.operation); + this._current.operation); } else { throw new Ice.ObjectNotExistException(this._current.id, this._current.facet, - this._current.operation); + this._current.operation); } } } @@ -562,8 +564,9 @@ var IncomingAsync = Ice.Class({ } this._connection = null; - }, - startReadParams: function() + } + + startReadParams() { // // Remember the encoding used by the input parameters, we'll @@ -571,21 +574,25 @@ var IncomingAsync = Ice.Class({ // this._current.encoding = this._is.startEncapsulation(); return this._is; - }, - endReadParams: function() + } + + endReadParams() { this._is.endEncapsulation(); - }, - readEmptyParams: function() + } + + readEmptyParams() { this._current.encoding = this._is.skipEmptyEncapsulation(); - }, - readParamEncaps: function() + } + + readParamEncaps() { this._current.encoding = new Ice.EncodingVersion(); return this._is.readEncapsulation(this._current.encoding); - }, - __response: function() + } + + __response() { try { @@ -611,8 +618,9 @@ var IncomingAsync = Ice.Class({ { this._connection.invokeException(ex, 1); } - }, - __exception: function(exc) + } + + __exception(exc) { try { @@ -627,8 +635,9 @@ var IncomingAsync = Ice.Class({ { this._connection.invokeException(ex, 1); } - }, - __validateResponse: function(ok) + } + + __validateResponse(ok) { if(!this._active) { @@ -636,8 +645,9 @@ var IncomingAsync = Ice.Class({ } this._active = false; return true; - }, - ice_exception: function(ex) + } + + ice_exception(ex) { if(!this._active) { @@ -660,7 +670,7 @@ var IncomingAsync = Ice.Class({ } } } -}); +} Ice.IncomingAsync = IncomingAsync; module.exports.Ice = Ice; |