-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add socket.io ack support #35
Conversation
socket.emitWithAck("message", ["Hello world!"]).then( (data) { // this callback runs when this specific message is acknowledged by the server print(data); }); When ACK is requested, a Future is returned, which will be completed once the server acknowledges the request. Note that there is no guarantee that the server will ever acknowledge the request, and the current implementation does not provide any timeout or garbage collection mechanism.
arguments = arguments.where((_) { | ||
//TODO this works around difference in ios (doesn't eat nulls) and android (eats nulls) | ||
return _ != null; | ||
}).toList().map((_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This toList
can be skipped as .map
is applicable on an Iterable
@@ -98,6 +129,18 @@ class SocketIO { | |||
'arguments': arguments, | |||
}); | |||
} | |||
///send data to socket server, return expected Ack as a Future | |||
emitWithAck(String eventName, List<dynamic> arguments) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A return type in method signature would be good as it is returning!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vornado22 an example to test in example/socket.io.server/index.js
would be great!
I'm having this error when trying to run it on branch master, and it might be related with the pull request :
|
Add callback support upon server ack after emit: