Skip to content

Commit

Permalink
Merge pull request #237 from chatziko/master
Browse files Browse the repository at this point in the history
Allow sending an ack with multiple data items (making it consistent with emit)
  • Loading branch information
jumperchen authored Nov 19, 2021
2 parents 97e3467 + 286e831 commit e6d0cc1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/src/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,25 @@ class Socket extends EventEmitter {
/// @api private
Function ack(id) {
var sent = false;
return (_) {
return (dynamic data) {
// prevent double callbacks
if (sent) return;
sent = true;
_logger.fine('sending ack $_');
_logger.fine('sending ack $data');

var sendData = <dynamic>[];
if (data is ByteBuffer || data is List<int>) {
sendData.add(data);
} else if (data is Iterable) {
sendData.addAll(data);
} else if (data != null) {
sendData.add(data);
}

packet({
'type': ACK,
'id': id,
'data': [_]
'data': sendData
});
};
}
Expand Down

0 comments on commit e6d0cc1

Please sign in to comment.