voryx / ThruwayBundle

Bundle for building Real-time Apps in Symfony
98 stars 47 forks source link

How to connect client manager to current user session for exclusion/eligibility handling #85

Closed arm1n closed 6 years ago

arm1n commented 6 years ago

Hi there!

First of all thank you for efforts in setting up Thruway and this bundle for Symfony - the whole setup was easy and without any hassle. I'm facing an issue where I don't really know how to handle it correctly, let me describe my use case: I've setup the bundle including authentication and make use of both RPC and PubSub, whereas all clients are connected via JS from my angular application and use call & subscribe, my Symfony backend registers RPC and publishes messages.

So my scenario raising some questions is as follows:

1) A subscribed JS client issues a HTTP request (not a RPC call) 2) Symfony controller handle request and publishes a message

Now, when I'm using $this->container->get('thruway.client')->publish("topic", [$value]]); in my Symfony controller after request handling this will also send the message to the actual issuer of the HTTP request cause the injected service/client is not coupled to the current symfony user session/auth id, but uses an anonymous session, right?

Normally, to include the publisher you would need to use exclude_me=>false - so could you please advise me how I should best handle this scenario? Would it make any difference using a RPC call instead of a HTTP call - I guess not? Or do I have to extract the authId in the controller and set it via exclude manually? Or is there anything else I've missed - thanks for any help!

davidwdan commented 6 years ago

You'll need to include the wamp session id with the HTTP request and then exclude that id from your publish with exclude => [$sessionId]

arm1n commented 6 years ago

Ok thanks for your quick response and help - as this was only a question I am going to close this one now!