server for my chess game
Diffstat (limited to 'src/StreamTcp.js')
| -rw-r--r-- | src/StreamTcp.js | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/src/StreamTcp.js b/src/StreamTcp.js deleted file mode 100644 index 82306fe..0000000 --- a/src/StreamTcp.js +++ /dev/null @@ -1,18 +0,0 @@ -const Transform = require('stream').Transform - -class StreamTcp extends Transform { - _transform (chunk, enc, done) { - let buffer = chunk - while (buffer.length > 0) { - const length = buffer.readUInt16LE(0) - - const bufferSplitted = buffer.slice(4, length + 4) // 4 cause the length bytes is in buffer - buffer = buffer.slice(length + 4, buffer.length) // 4 cause the length bytes is in buffer - - this.push(bufferSplitted) - } - done() - } -} - -module.exports = StreamTcp
\ No newline at end of file |