From 04867944334fa8bef481353352969b7b131162ea Mon Sep 17 00:00:00 2001 From: wolf4ood Date: Wed, 25 Sep 2019 10:35:06 +0200 Subject: [PATCH] Fixes https://github.com/orientechnologies/orientdb/issues/9012 --- lib/client/database/session.js | 1 + lib/client/network/protocol37/operation.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/client/database/session.js b/lib/client/database/session.js index 62cc22a9..07547d72 100644 --- a/lib/client/database/session.js +++ b/lib/client/database/session.js @@ -165,6 +165,7 @@ class SessionManager { data.token = session.token; data.sessionId = session.sessionId; data.database = this.name; + data._session = session; data.db = this; data.transformerFunctions = db.transformerFunctions; this.client.logger.debug( diff --git a/lib/client/network/protocol37/operation.js b/lib/client/network/protocol37/operation.js index dafa5644..20a1fb53 100644 --- a/lib/client/network/protocol37/operation.js +++ b/lib/client/network/protocol37/operation.js @@ -85,7 +85,7 @@ Operation.prototype.buffer = function() { size += item[0]; } - buffer = Buffer.alloc(size); + buffer = Buffer.alloc(size); for (i = 0; i < total; i++) { item = commands[i]; @@ -305,7 +305,7 @@ Operation.prototype.writeVarintString = function(data) { }; function encodeString(data) { - return Buffer.from(data); + return Buffer.from(data); } // # Read Operations @@ -330,7 +330,11 @@ Operation.prototype.readStatus = function(fieldName, reader) { this.readByte("code"); this.readInt("sessionId"); - this.readBytes("token"); + this.readBytes("token", data => { + if (data.token && data.token.length > 0 && this.data._session) { + this.data._session.token = data.token; + } + }); this.readByte("op", next); return this; @@ -591,7 +595,7 @@ Operation.prototype.parseLivePush = function(buffer, offset, result) { offset += 1; let length = buffer.readInt32BE(offset); offset += 4; - let recordBuffer = Buffer.alloc(length); + let recordBuffer = Buffer.alloc(length); buffer.copy(recordBuffer, 0, offset, offset + length); offset += length; event.data = deserializer.deserialize(