I invite you to follow the procedure for session sharing and user authentication, as explained in the doc of the bundle you use: https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/Resources/docs/SessionSetup.md
First you need to implement a Symfony session handler, if you decide to use the PDO Session Handler, the doc is here: http://symfony.com/doc/master/cookbook/configuration/pdo_session_storage.html (Do not forget to create the corresponding DB if you chose so, declaring all the services, parameters, and so on).
Next, you have to set your config.yml to use your session handler:
framework:
...
session:
handler_id: session.handler.pdo # adapt if you chose a different one
Setup GOS Websocket for using it as well:
gos_web_socket:
...
client:
firewall: main # the name of your firewall (can be an array if multiple)
session_handler: @session.handler.pdo
The end of the documentation available at the first link will show you some ways of using your client manipulator. I know it is better to copy paste, but I really don't feel like copy pasting the entire doc is useful, nor clear.
For my own use, I do not have a client manipulator, I simply use
$this->clientStorage->getClient($connection->WAMP->clientStorageId);
in order to retrieve the user with the current connection. The clientStorage
is available if you give it (@gos_web_socket.client_storage
) to the service constructor as argument. Of course, you need to adapt your constructor:
class AcmeTopic implements TopicInterface
{
/**
* @param ClientStorageInterface $clientStorage
*/
protected $clientStorage;
public function __construct(ClientStorageInterface $clientStorage)
{
...
To access other users, you can take some inspiration from:
foreach($topic as $subscriber)
{
$subscriber->event($topic->getId(),
['msg' => $this->clientStorage
->getClient($connection->WAMP->clientStorageId)
->getUsername().' is now online!']);
}
Hope this helps, I do not have that much experience with it, as it is my first use as well. I invite you to ask directly on the GitHub if you are still stuck (issues part), as the author can probably help you more!
(Also, I assumed you use the Topic)