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

PublishMessage eligible #2

Open
her-ur opened this issue Oct 5, 2018 · 2 comments
Open

PublishMessage eligible #2

her-ur opened this issue Oct 5, 2018 · 2 comments

Comments

@her-ur
Copy link

her-ur commented Oct 5, 2018

Hello, I am using eligible option when I am publishing messages. Here https://github.com/voryx/Thruway/blob/master/src/Transport/InternalClientTransportProvider.php#L49 is all message converted to stdClass by json_decode(json_encode($msg)) and when is message recreated here https://github.com/voryx/ThruwayCommon/blob/master/src/Message/PublishMessage.php#L159, there is a problem with this condition

$this->eligible = isset($options->eligible) && is_array($options->eligible) ? $options->eligible : null;

because $options->eligible is stdClass and not an array, eligible property is not set and messages are then broadcasted to everyone.
I think it's bug. How that can be fixed? If you give me some details please I can submit a PR.
Thank you!

@mbonneau
Copy link
Member

mbonneau commented Oct 5, 2018

@her-ur Eligible should be an array or list of session ids, so when it get serialized, it should be converted to a JSON array.

Can you show me the code that you are using?

@her-ur
Copy link
Author

her-ur commented Oct 5, 2018

Of course, this is called in class that extends Thruway\Peer\Client and is used as router module.

$this->getSession()->publish($topic->getValue(), [$message], [], ['eligible' => $this->sessions[$userPublicToken]]);

$this->sessions[$userPublicToken] is array of session ids. Weird is that sometimes its working fine, but when i am refreshing pages it goes wrong as I described above.

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

No branches or pull requests

2 participants