WebSocketBundle icon indicating copy to clipboard operation
WebSocketBundle copied to clipboard

Send Private message to receiver AND sender ONLY

Open Axel-KIRK opened this issue 6 years ago • 1 comments

Hi we we to display the message to both of the sender and the receiver of the private message. This code work to show only to the receiver : `if ($topic->getId() === 'chat/private') {

            $receiver = $this->clientManipulator->findByUsername($topic, $event['receiver']);
            

            $topic->broadcast(
                [
                'sender' => $user->getUsername(),
                'message' => 'message privé: '. $event['message'],
                ],
                array(),
                array($receiver['connection']->WAMP->sessionId, )
                );`

But this code never work, we try to allow the sender of ther private message to see his own message : ` if ($topic->getId() === 'chat/private') {

            $receiver = $this->clientManipulator->findByUsername($topic, $event['receiver']);
            $senderMp = $this->clientManipulator->findByUsername($topic, $event[$user->getUsername()]);
        
        

            $topic->broadcast(
                [
                'sender' => $user->getUsername(),
                'message' => 'message privé: '. $event['message'],
                ],
                array(),
                array($receiver['connection']->WAMP->sessionId, $senderMp['connection']->WAMP->sessionId)
                );`

We also try to add 'somewhere', we don't know really where the $connection->event($topic->getId(), ['msg' => 'lol']); but never works too...

Have some idea about ?

Axel-KIRK avatar Sep 13 '18 21:09 Axel-KIRK

any solution?

thehatami avatar Mar 11 '19 08:03 thehatami