Fix error in example (#701)

* Fix error in example

This fixes an error that occurs with the example echo client:
```TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object```
This change might be needed in the server as well, but I didn't test that. Or maybe there's a better way to fix this

* Fix Browserify and Webpack

* Actually fix Browserify/Webpack

* ACTUALLY actually fix Browserify/Webpack

* Surely this will fix Browserify/Webpack
This commit is contained in:
Heath123 2020-05-03 11:16:30 +01:00 committed by GitHub
parent 28b52a9158
commit bba58c8d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -70,7 +70,7 @@ client.on('chat', function(packet) {
var username = jsonMsg.with[0].text;
var msg = jsonMsg.with[1];
if(username === client.username) return;
client.write('chat', {message: msg});
client.write('chat', {message: msg.text});
}
});
```

View file

@ -52,7 +52,7 @@ class Decompressor extends Transform {
this.push(chunk.slice(size))
return cb()
} else {
zlib.unzip(chunk.slice(size), { finishFlush: zlib.constants.Z_SYNC_FLUSH }, (err, newBuf) => { /** Fix by lefela4. */
zlib.unzip(chunk.slice(size), { finishFlush: 2 /* Z_SYNC_FLUSH = 2, but when using Browserify/Webpack it doesn't exist */ }, (err, newBuf) => { /** Fix by lefela4. */
if (err) {
if (!this.hideErrors) {
console.error('problem inflating chunk')