@@ -85,7 +85,7 @@ WebSocketFrame.prototype.addData = function(bufferList) {
85
85
if ( bufferList . length >= 2 ) {
86
86
bufferList . joinInto ( this . frameHeader , 2 , 0 , 2 ) ;
87
87
bufferList . advance ( 2 ) ;
88
- this . length = this . frameHeader . readUInt16BE ( 2 , true ) ;
88
+ this . length = this . frameHeader . readUInt16BE ( 2 ) ;
89
89
this . parseState = WAITING_FOR_MASK_KEY ;
90
90
}
91
91
}
@@ -94,10 +94,10 @@ WebSocketFrame.prototype.addData = function(bufferList) {
94
94
bufferList . joinInto ( this . frameHeader , 2 , 0 , 8 ) ;
95
95
bufferList . advance ( 8 ) ;
96
96
var lengthPair = [
97
- this . frameHeader . readUInt32BE ( 2 , true ) ,
98
- this . frameHeader . readUInt32BE ( 2 + 4 , true )
97
+ this . frameHeader . readUInt32BE ( 2 ) ,
98
+ this . frameHeader . readUInt32BE ( 2 + 4 )
99
99
] ;
100
-
100
+
101
101
if ( lengthPair [ 0 ] !== 0 ) {
102
102
this . protocolError = true ;
103
103
this . dropReason = 'Unsupported 64-bit length frame received' ;
@@ -149,7 +149,7 @@ WebSocketFrame.prototype.addData = function(bufferList) {
149
149
this . invalidCloseFrameLength = true ;
150
150
}
151
151
if ( this . length >= 2 ) {
152
- this . closeStatus = this . binaryPayload . readUInt16BE ( 0 , true ) ;
152
+ this . closeStatus = this . binaryPayload . readUInt16BE ( 0 ) ;
153
153
this . binaryPayload = this . binaryPayload . slice ( 2 ) ;
154
154
}
155
155
}
@@ -204,7 +204,7 @@ WebSocketFrame.prototype.toBuffer = function(nullMask) {
204
204
this . length += this . binaryPayload . length ;
205
205
}
206
206
data = new Buffer ( this . length ) ;
207
- data . writeUInt16BE ( this . closeStatus , 0 , true ) ;
207
+ data . writeUInt16BE ( this . closeStatus , 0 ) ;
208
208
if ( this . length > 2 ) {
209
209
this . binaryPayload . copy ( data , 2 ) ;
210
210
}
@@ -242,20 +242,20 @@ WebSocketFrame.prototype.toBuffer = function(nullMask) {
242
242
243
243
if ( this . length > 125 && this . length <= 0xFFFF ) {
244
244
// write 16-bit length
245
- output . writeUInt16BE ( this . length , outputPos , true ) ;
245
+ output . writeUInt16BE ( this . length , outputPos ) ;
246
246
outputPos += 2 ;
247
247
}
248
248
else if ( this . length > 0xFFFF ) {
249
249
// write 64-bit length
250
- output . writeUInt32BE ( 0x00000000 , outputPos , true ) ;
251
- output . writeUInt32BE ( this . length , outputPos + 4 , true ) ;
250
+ output . writeUInt32BE ( 0x00000000 , outputPos ) ;
251
+ output . writeUInt32BE ( this . length , outputPos + 4 ) ;
252
252
outputPos += 8 ;
253
253
}
254
254
255
255
if ( this . mask ) {
256
- maskKey = nullMask ? 0 : ( Math . random ( ) * 0xFFFFFFFF ) | 0 ;
257
- this . maskBytes . writeUInt32BE ( maskKey , 0 , true ) ;
258
-
256
+ maskKey = nullMask ? 0 : ( ( Math . random ( ) * 0xFFFFFFFF ) >>> 0 ) ;
257
+ this . maskBytes . writeUInt32BE ( maskKey , 0 ) ;
258
+
259
259
// write the mask key
260
260
this . maskBytes . copy ( output , outputPos ) ;
261
261
outputPos += 4 ;
0 commit comments