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

push function not property explained #372

Open
thehatami opened this issue Mar 2, 2019 · 2 comments
Open

push function not property explained #372

thehatami opened this issue Mar 2, 2019 · 2 comments

Comments

@thehatami
Copy link

thehatami commented Mar 2, 2019

need more explaine about "push" function. i cant undrestant this line

$pusher->push(['my_data' => 'data'], 'user_notification', ['username' => 'user1']);

please review the readme.md

@thehatami thehatami changed the title "gos_web_socket.amqp.pusher" not found push function not property explained Mar 2, 2019
@stipic
Copy link

stipic commented Mar 3, 2019

['my_data' => 'data'] = Payload
user_notification = name of your PubSub route
['username' => 'user1'] = params for your PubSub route (if needed)

example:

Let's say i have app_topic_chat PubSub route in my yaml file:

app_topic_chat:
    channel: 'conversation/{conversationId}'
    handler:
        callback: 'conversation.topic'
    requirements:
        conversationId:
            pattern: '\d+'

My push action for that topic will be something like this:

$this->_pusher->push($payload, 'app_topic_chat', ['conversationId' => 1]);

If you use let's say ZMQ pusher then your topic MUST implement PushableTopicInterface

use Gos\Bundle\WebSocketBundle\Topic\PushableTopicInterface;

And that interface will force you to add new method in your topic handler

public function onPush(Topic $topic, $request, $payload, $provider)
{
      $topic->broadcast(json_encode($payload));
}

@thehatami
Copy link
Author

thank you stipic. but by all this, i cant send a message to specific user and only receive default broadcast like

Received message 936 has left foor/bar

how can i sent msg from my controller to pusher?

i try (like this)

$pusher->push(['data' => 'data'], 'user_notification', ['conversationId' => 939]);

and i get

Library error: connection closed unexpectedly - Potential login failure.

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