add some debugging things

This commit is contained in:
hippoz 2021-02-27 01:56:46 +02:00
parent e13b10fedf
commit df6aee135c
No known key found for this signature in database
GPG key ID: 7C52899193467641
3 changed files with 9 additions and 3 deletions

View file

@ -7,7 +7,7 @@
<script> <script>
let theFunniestStringEver = ''; let theFunniestStringEver = '';
for (let i = 0; i < 1000000; i++) { for (let i = 0; i < 100000; i++) {
theFunniestStringEver += 'h'; theFunniestStringEver += 'h';
} }

View file

@ -55,6 +55,8 @@ const parseWebsocketFrame = (data) => {
const frame = new WebsocketFrame(); const frame = new WebsocketFrame();
console.log(firstByte.toString(2));
// 1 byte - first byte // 1 byte - first byte
frame.FIN = (firstByte >> 7); // >> 7 - Get most significant bit (FIN) frame.FIN = (firstByte >> 7); // >> 7 - Get most significant bit (FIN)
frame.RSVx = (firstByte & 0x70) >> 4; // 0x70[0b01110000] - Get the 3 bits after the most significant bit (RSVx) frame.RSVx = (firstByte & 0x70) >> 4; // 0x70[0b01110000] - Get the 3 bits after the most significant bit (RSVx)

View file

@ -22,8 +22,12 @@ class Socket extends EventEmitter {
console.log(packet); console.log(packet);
if (this._buffering && packet.FIN === 1) { if (this._buffering && packet.FIN === 1) {
try {
this.emit('binary', Buffer.concat([this._buffering, packet.PayloadData])); this.emit('binary', Buffer.concat([this._buffering, packet.PayloadData]));
this._buffering = undefined; this._buffering = undefined;
} catch (e) {
console.error(e);
}
} }
if (packet.FIN === 0) { if (packet.FIN === 0) {