diff --git a/lib/units/device/plugins/vnc/util/vncserver.js b/lib/units/device/plugins/vnc/util/vncserver.js index f884b647..129f4aae 100644 --- a/lib/units/device/plugins/vnc/util/vncserver.js +++ b/lib/units/device/plugins/vnc/util/vncserver.js @@ -56,6 +56,7 @@ function VncConnection(conn) { this._clientPixelFormat = this._serverPixelFormat this._clientEncodingCount = 0 this._clientEncodings = [] + this._clientCutTextLength = 0 this.conn = conn .on('readable', this._bound._readableListener) @@ -90,11 +91,12 @@ var StateReverse = Object.create(null), State = { , STATE_NEED_CLIENT_MESSAGE: 40 , STATE_NEED_CLIENT_MESSAGE_SETPIXELFORMAT: 50 , STATE_NEED_CLIENT_MESSAGE_SETENCODINGS: 60 -, STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_ARRAY: 61 +, STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_VALUE: 61 , STATE_NEED_CLIENT_MESSAGE_FBUPDATEREQUEST: 70 , STATE_NEED_CLIENT_MESSAGE_KEYEVENT: 80 , STATE_NEED_CLIENT_MESSAGE_POINTEREVENT: 90 , STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT: 100 +, STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT_VALUE: 101 } Object.keys(State).map(function(name) { @@ -258,10 +260,10 @@ VncConnection.prototype._read = function() { if ((chunk = this._consume(3))) { // [0b, 1b) padding this._clientEncodingCount = chunk.readUInt16BE(1, true) - this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_ARRAY) + this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_VALUE) } break - case VncConnection.STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_ARRAY: + case VncConnection.STATE_NEED_CLIENT_MESSAGE_SETENCODINGS_VALUE: lo = 0 hi = 4 * this._clientEncodingCount if ((chunk = this._consume(hi))) { @@ -303,10 +305,18 @@ VncConnection.prototype._read = function() { case VncConnection.STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT: if ((chunk = this._consume(7))) { // [0b, 3b) padding - // length = chunk.readUInt32BE(3) - this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT_VALUE) + this._clientCutTextLength = chunk.readUInt32BE(3) + this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT_STRING) } break + case VncConnection.STATE_NEED_CLIENT_MESSAGE_CLIENTCUTTEXT_VALUE: + if ((chunk = this._consume(this._clientCutTextLength))) { + // value = chunk + this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE) + } + break + default: + throw new Error(util.format('Impossible state %d', this._state)) } } while (chunk)