Skip to content

Commit

Permalink
Freezing of Options in Progressive Call Invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Jul 10, 2023
1 parent 8a00b45 commit ea7cb29
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions router/dealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type invocation struct {
canceled bool
inProgress bool
timerCancel context.CancelFunc
options wamp.Dict
}

type requestID struct {
Expand Down Expand Up @@ -698,19 +699,24 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {
callID: reqID,
callee: callee,
inProgress: isInProgress,
options: msg.Options,
}
d.invocations[invocationID] = invk
d.invocationByCall[reqID] = invocationID

} else {
storedInvk := d.invocations[storedInvocationID]
storedInvk.inProgress = isInProgress
callee = storedInvk.callee
invk = d.invocations[storedInvocationID]
invk.inProgress = isInProgress
callee = invk.callee
invocationID = storedInvocationID
}

// Let's check if callee supports this feature
if isInProgress && !callee.HasFeature(wamp.RoleCallee, wamp.FeatureProgCallInvocations) {
// A Callee that supports progressive call invocations, but does not support call canceling,
// shall be considered by the Dealer as not supporting progressive call invocations.
if isInProgress &&
(!callee.HasFeature(wamp.RoleCallee, wamp.FeatureProgCallInvocations) ||
!callee.HasFeature(wamp.RoleCallee, wamp.FeatureCallCanceling)) {
d.trySend(caller, &wamp.Error{
Type: msg.MessageType(),
Request: msg.Request,
Expand All @@ -728,7 +734,7 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {
//
// A timeout allows to automatically cancel a call after a specified time
// either at the Callee or at the Dealer.
timeout, _ := wamp.AsInt64(msg.Options[wamp.OptTimeout])
timeout, _ := wamp.AsInt64(invk.options[wamp.OptTimeout])
if timeout > 0 {
// Check that callee supports call_timeout.
if callee.HasFeature(wamp.RoleCallee, wamp.FeatureCallTimeout) {
Expand All @@ -742,7 +748,7 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {

// Check and handle Payload PassThru Mode
// @see https://wamp-proto.org/wamp_latest_ietf.html#name-payload-passthru-mode
if pptScheme, _ := msg.Options[wamp.OptPPTScheme].(string); pptScheme != "" {
if pptScheme, _ := invk.options[wamp.OptPPTScheme].(string); pptScheme != "" {

// Let's check: was ppt feature announced by caller?
if !caller.HasFeature(wamp.RoleCaller, wamp.FeaturePayloadPassthruMode) {
Expand Down Expand Up @@ -770,7 +776,7 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {

// Every side supports PPT feature
// Let's fill PPT options for callee
pptOptionsToDetails(msg.Options, details)
pptOptionsToDetails(invk.options, details)
}

// If the callee has requested disclosure of caller identity when the
Expand All @@ -784,7 +790,7 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {
// A Caller MAY request the disclosure of its identity (its WAMP
// session ID) to endpoints of a routed call. This is indicated by the
// "disclose_me" flag in the message options.
if opt, _ := msg.Options[wamp.OptDiscloseMe].(bool); opt {
if opt, _ := invk.options[wamp.OptDiscloseMe].(bool); opt {
// Dealer MAY deny a Caller's request to disclose its identity.
if !d.allowDisclose {
// Do not continue a call when discloseMe was disallowed.
Expand All @@ -804,7 +810,7 @@ func (d *dealer) syncCall(caller *wamp.Session, msg *wamp.Call) {

// A Caller indicates its willingness to receive progressive results by
// setting CALL.Options.receive_progress|bool := true
if opt, _ := msg.Options[wamp.OptReceiveProgress].(bool); opt {
if opt, _ := invk.options[wamp.OptReceiveProgress].(bool); opt {
// If the Callee supports progressive calls, the Dealer will forward
// the Caller's willingness to receive progressive results by setting.
//
Expand Down

0 comments on commit ea7cb29

Please sign in to comment.