Git Product home page Git Product logo

Comments (7)

jjsaunier avatar jjsaunier commented on June 3, 2024

Yes you can,

you will need WampRouter service to achieve that (@gos_web_socket.router.wamp)

    /**
     * @param WampRouter                 $wampRouter
     */
    public function __construct(WampRouter $wampRouter)
    {
        $this->wampRouter = $wampRouter;
    }

Choose on wich event you want do that :

$connection->event($this->wampRouter->generate('target_topic_route_name'), 'message'');

from websocketbundle.

ewertoncode avatar ewertoncode commented on June 3, 2024

Sorry, but I don't understand very well...

I should to do:

public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
    {
...
//My condition for it ...
$connection->send($this->wampRouter->generate('chat_topic', ['room' => 'all']), ['msg' => 'notification']); 

//Send the message for all subscribers this private topic
$topic->broadcast(
            [
                'msg' => "<b>".$this->getCurrentUser($connection)->getUsername()."</b>: ".$event,
            ]
        );
...

My problem is: I have a chat private, I would like, if one of the participants from chat is not present, notify it.

Thanks!
Sorry to bother @Prophet777 ...

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

You don't need that so, they are on the same topic right ? If yes

You can simply send notification message type when unsubscribe is called. From $connection of unsubscribe you can get the user and then generate your notification. Add just an entry "type" in your response to deal in your front end.

'type' => 'notification', 'msg' => "<b>".$this->getCurrentUser($connection)->getUsername()."</b>: ".$event,

You should also look at the lastest version https://github.com/GeniusesOfSymfony/WebSocketBundle/releases/tag/v1.3.0, Auth user have been improved and getCurrentUser is deprecated. Look #28

Other thing in the lastest version, when connection is closed by client it automatically call unsubscribe of each subsribed topic #31

from websocketbundle.

ewertoncode avatar ewertoncode commented on June 3, 2024

They are not on the same topic.

I have a general chat (chat/chanel/all) and individual chat (chat/chanel/10x13: indicating that the conversation is between userId 10 e 13). When a user starts the chat, I would like to notify you (until he subscribe this private chat), that there is someone talking to him.

I did the update to the new version, the $this->clientManipulator->getClient ($connection), worked fine.

Thank you again!!! :D

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

Actually you can't but with ZMQ (#36) we can find a way to achieve that ;)

I also have create a PoC #38

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

I'm on it :)

from websocketbundle.

jjsaunier avatar jjsaunier commented on June 3, 2024

Take a look at #38

from websocketbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.