WebSocketBundle
WebSocketBundle copied to clipboard
Send Private message to receiver AND sender ONLY
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 ?
any solution?