Skip to content
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 unsubscribe feature for client #196

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

vyk12
Copy link

@vyk12 vyk12 commented May 13, 2016

This Pull Request implements unsubscribe feature for the client. Please let me know if I missed something!

* @param \Thruway\AbstractSession $session
* @param \Thruway\Message\ErrorMessage $msg
*/
protected function processUnsubscribeError(AbstractSession $session, ErrorMessage $msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be called processUnsubscribe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is called whenever the router responds with an ERROR message. Why should it be called processUnsubscribe? It follows the same logic as processSubscribeError.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processUnsubscribeError is correct. Only the broker would handle the UNSUBSCRIBE message.

@davidwdan
Copy link
Member

@mbonneau Just took a quick look at this. We should write some tests and also figure out why PHP7 tests are failing.

return;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the spec say anything about what the client should do if there is an error unsubscribing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* process unsubscribe
* @param ClientSession $session
* @param string $subscriptionId
* @return boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do see that this actually returns promise - the docblock just needs updated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this has been fixed

@mbonneau
Copy link
Member

@vyk12 This is looking pretty good. I would like to get some tests for it if you have a chance - or let me know and I can see if I can find some time to write some tests.

foreach ($this->subscriptions as $key => $subscription) {
if ($subscription["unsubscribed_request_id"] === $msg->getErrorRequestId()) {
// reject the promise
$subscription['unsubscribed_deferred']->reject($msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this deferred used anywhere? I see pieces of this idea in the code but I don't think it is used anywhere - we may be able to get rid of it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deferred is the one that wraps the promise returned by the unsubscribe method, so yes, it is used (and is kind of important.) Or I didn't understand what you meant?

@vyk12
Copy link
Author

vyk12 commented May 26, 2016

@mbonneau I haven't checked yet the way you wrote your phpunit tests, and I have to admit that I am not yet really familiar with it. I think it would be better that you take care of it. However, if you have multiple tests to write, maybe you can write a couple of these and I'll see what I can do to help to write others.

By the way, I intend to update the unsubscribe part of the documentation to indicate that it is implemented. I can also update the /Examples/SimpleClient.php and/or the /Examples/ClientExample.php to show how to use it, you tell me.

@vyk12
Copy link
Author

vyk12 commented Jun 17, 2016

@mbonneau @davidwdan Any news about this PR?

@mbonneau
Copy link
Member

Hi @vyk12 ,

I would like to see some tests of this before merging - I will get to work on that when I have a moment so that we can merge this.

Thanks

@davidwdan davidwdan added this to the 0.5.1 milestone Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants