From 5fada1f697831f2fcbdf75024c0b5a27849d623d Mon Sep 17 00:00:00 2001 From: Jumper Chen Date: Fri, 27 Dec 2019 11:07:56 +0800 Subject: [PATCH] fine tune and add the contributor @ThinkDigitalSoftware for #15 --- README.md | 1 + lib/src/namespace.dart | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e65369c..2f352f4 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,4 @@ If you are new to Git or GitHub, please read [this guide](https://help.github.co ## Contributors * Thanks [@felangel](https://github.com/felangel) for https://github.com/rikulo/socket.io-dart/issues/7 +* Thanks [@ThinkDigitalSoftware](https://github.com/ThinkDigitalSoftware) for https://github.com/rikulo/socket.io-dart/pull/15 \ No newline at end of file diff --git a/lib/src/namespace.dart b/lib/src/namespace.dart index 1e2f741..438e0e7 100644 --- a/lib/src/namespace.dart +++ b/lib/src/namespace.dart @@ -87,7 +87,7 @@ class Namespace extends EventEmitter { if (err) return fn(err); // if no middleware left, summon callback - if (fns.length < index + 1) return fn(null); + if (fns.length <= index + 1) return fn(null); // go on to next run0(index + 1, fns, socket, fn); @@ -189,12 +189,13 @@ class Namespace extends EventEmitter { /// /// @return {Namespace} self /// @api public - void send([args]) { - write(args); + Namespace send([args]) { + return write(args); } - void write([args]) { + Namespace write([args]) { emit('message', args); + return this; } /// Gets a list of clients. @@ -213,10 +214,12 @@ class Namespace extends EventEmitter { /// Sets the compress flag. /// /// @param {Boolean} if `true`, compresses the sending data + /// @return {Namespace} self /// @api public - void compress(compress) { + Namespace compress(compress) { flags = flags.isEmpty ? flags : {}; flags['compress'] = compress; + return this; } }