Skip to content

Commit

Permalink
Merge pull request #86 from muzzammilshahid/handle-progress-yield-result
Browse files Browse the repository at this point in the history
Handle progress yield and invocation
  • Loading branch information
muzzammilshahid authored Dec 26, 2024
2 parents 025eac8 + 636026f commit 3c35228
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/src/joiner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import "package:wampproto/src/types.dart";

final clientRoles = <String, Map<String, Map>>{
"caller": {"features": {}},
"callee": {"features": {}},
"callee": {
"features": {
"progressive_call_results": true,
"call_canceling": true,
},
},
"publisher": {"features": {}},
"subscriber": {"features": {}},
};
Expand Down
12 changes: 9 additions & 3 deletions lib/src/session.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "package:wampproto/messages.dart";
import "package:wampproto/serializers.dart";
import "package:wampproto/src/dealer.dart";
import "package:wampproto/src/exception.dart";

class WAMPSession {
Expand Down Expand Up @@ -37,7 +38,10 @@ class WAMPSession {
if (!_invocationRequests.containsKey(msg.requestID)) {
throw ArgumentError("cannot yield for unknown invocation request");
}
_invocationRequests.remove(msg.requestID);
bool progress = msg.options[optionProgress] ?? false;
if (!progress) {
_invocationRequests.remove(msg.requestID);
}

return _serializer.serialize(msg);
} else if (msg is Publish) {
Expand Down Expand Up @@ -78,8 +82,10 @@ class WAMPSession {
if (!_callRequests.containsKey(msg.requestID)) {
throw ProtocolError("received RESULT for invalid request ID ${msg.requestID}");
}
_callRequests.remove(msg.requestID);

bool progress = msg.details["progress"] ?? false;
if (!progress) {
_callRequests.remove(msg.requestID);
}
return msg;
} else if (msg is Registered) {
if (!_registerRequests.containsKey(msg.requestID)) {
Expand Down

0 comments on commit 3c35228

Please sign in to comment.