mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:53:23 +02:00
fix deprecated warnings on Buffer class (#580)
Signed-off-by: Denis barbaron <denis.barbaron@orange.com> Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
@@ -120,14 +120,14 @@ VncConnection.prototype.end = function() {
|
||||
}
|
||||
|
||||
VncConnection.prototype.writeFramebufferUpdate = function(rectangles) {
|
||||
var chunk = new Buffer(4)
|
||||
var chunk = Buffer.alloc(4)
|
||||
chunk[0] = VncConnection.SERVER_MESSAGE_FBUPDATE
|
||||
chunk[1] = 0
|
||||
chunk.writeUInt16BE(rectangles.length, 2)
|
||||
this._write(chunk)
|
||||
|
||||
rectangles.forEach(function(rect) {
|
||||
var rchunk = new Buffer(12)
|
||||
var rchunk = Buffer.alloc(12)
|
||||
rchunk.writeUInt16BE(rect.xPosition, 0)
|
||||
rchunk.writeUInt16BE(rect.yPosition, 2)
|
||||
rchunk.writeUInt16BE(rect.width, 4)
|
||||
@@ -171,19 +171,19 @@ VncConnection.prototype._writeServerVersion = function() {
|
||||
// Yes, we could just format the string instead. Didn't feel like it.
|
||||
switch (this._serverVersion) {
|
||||
case VncConnection.V3_003:
|
||||
this._write(new Buffer('RFB 003.003\n'))
|
||||
this._write(Buffer.from('RFB 003.003\n'))
|
||||
break
|
||||
case VncConnection.V3_007:
|
||||
this._write(new Buffer('RFB 003.007\n'))
|
||||
this._write(Buffer.from('RFB 003.007\n'))
|
||||
break
|
||||
case VncConnection.V3_008:
|
||||
this._write(new Buffer('RFB 003.008\n'))
|
||||
this._write(Buffer.from('RFB 003.008\n'))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
VncConnection.prototype._writeSupportedSecurity = function() {
|
||||
var chunk = new Buffer(1 + this._serverSupportedSecurity.length)
|
||||
var chunk = Buffer.alloc(1 + this._serverSupportedSecurity.length)
|
||||
|
||||
chunk[0] = this._serverSupportedSecurity.length
|
||||
this._serverSupportedSecurity.forEach(function(security, i) {
|
||||
@@ -197,12 +197,12 @@ VncConnection.prototype._writeSecurityResult = function(result, reason) {
|
||||
var chunk
|
||||
switch (result) {
|
||||
case VncConnection.SECURITYRESULT_OK:
|
||||
chunk = new Buffer(4)
|
||||
chunk = Buffer.alloc(4)
|
||||
chunk.writeUInt32BE(result, 0)
|
||||
this._write(chunk)
|
||||
break
|
||||
case VncConnection.SECURITYRESULT_FAIL:
|
||||
chunk = new Buffer(4 + 4 + reason.length)
|
||||
chunk = Buffer.alloc(4 + 4 + reason.length)
|
||||
chunk.writeUInt32BE(result, 0)
|
||||
chunk.writeUInt32BE(reason.length, 4)
|
||||
chunk.write(reason, 8, reason.length)
|
||||
@@ -213,7 +213,7 @@ VncConnection.prototype._writeSecurityResult = function(result, reason) {
|
||||
|
||||
VncConnection.prototype._writeServerInit = function() {
|
||||
debug('server pixel format', this._serverPixelFormat)
|
||||
var chunk = new Buffer(2 + 2 + 16 + 4 + this._serverName.length)
|
||||
var chunk = Buffer.alloc(2 + 2 + 16 + 4 + this._serverName.length)
|
||||
chunk.writeUInt16BE(this._serverWidth, 0)
|
||||
chunk.writeUInt16BE(this._serverHeight, 2)
|
||||
chunk[4] = this._serverPixelFormat.bitsPerPixel
|
||||
@@ -459,15 +459,15 @@ VncConnection.prototype._unguardedRead = function() {
|
||||
}
|
||||
|
||||
VncConnection.prototype._parseVersion = function(chunk) {
|
||||
if (chunk.equals(new Buffer('RFB 003.008\n'))) {
|
||||
if (chunk.equals(Buffer.from('RFB 003.008\n'))) {
|
||||
return VncConnection.V3_008
|
||||
}
|
||||
|
||||
if (chunk.equals(new Buffer('RFB 003.007\n'))) {
|
||||
if (chunk.equals(Buffer.from('RFB 003.007\n'))) {
|
||||
return VncConnection.V3_007
|
||||
}
|
||||
|
||||
if (chunk.equals(new Buffer('RFB 003.003\n'))) {
|
||||
if (chunk.equals(Buffer.from('RFB 003.003\n'))) {
|
||||
return VncConnection.V3_003
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user