title: Symfony 5 Private chat with Pusher
body: <p>I've created a simple group chat application with <code>Symfony 5</code>, and now I'm trying to add <code>Socket</code> with <code>Pusher</code>.</p>
  <p>For the moment it's working, but because I'm using a single <code>channel</code>, everytime a user post a message, this message appears on every conversation. That's why I would like to pass the <code>messaging_id</code> in the <code>channel name</code>, but it's not working.</p>
  <p>I read on the doc I should use the prefix <code>private-</code> in my <code>channel name</code>, but with this the console is asking me to auth the user, and I don't know how do it because my user is already connected.</p>
  <p>Here is my logic <strong>controller</strong> :</p>
  <pre><code> // Pusher
          $options = array(
              'cluster' =&gt; 'eu',
              'useTLS' =&gt; true
          );
          $pusher = new Pusher(
              'ba75523bee28d7c644f2',
              '9597b6daf0fb4e20fda2',
              '1266737',
              $options
          );
  
          //New message
          $message = new Message();
          $form = $this-&gt;createForm(MessageType::class, $message);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $message-&gt;setAuthor($user);
              $message-&gt;setMessaging($messaging);
              $entityManager = $this-&gt;getDoctrine()-&gt;getManager();
              $entityManager-&gt;persist($message);
              $entityManager-&gt;flush();
  
              $data = $message-&gt;getContent();
  
              if ($pusher-&gt;trigger('my-channel', 'my_event', $data)) {
                  echo 'success';
              } else {
                  header('', true, 403);
                  echo 'error';
              }
  
              return new JsonResponse(Response::HTTP_OK);
          }
  </code></pre>
  <p>Here is my <strong>Javascript</strong> :</p>
  <pre><code>Pusher.logToConsole = true;
  
  var pusher = new Pusher('ba75523bee28d7c644f2', {
      cluster: 'eu',
  });
  
  var channel = pusher.subscribe('my-channel');
  
  channel.bind('my_event',
      function (data) {
          console.log(data);
          $('.lala').append('&lt;li class = &quot;chat-left&quot;&gt;&lt;div class=&quot;chat-text&quot;&gt;' + data + '&lt;/div&gt;');
      });
  
  channel.bind('pusher:subscription_succeeded', function (members) {
      console.log('successfully subscribed!');
  });
  
  function ajaxCall(ajax_url, ajax_data) {
      $.ajax({
          type: &quot;POST&quot;,
          url: ajax_url,
          dataType: &quot;json&quot;,
          data: ajax_data,
          success: function (response) {
              console.log(response);
          },
          error: function (msg) { }
      });
  }
  </code></pre>
  <p>Here is the error if I use the <code>private-</code> prefix :
  <a href="https://i.stack.imgur.com/aMg2P.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>To summarize, I would like every message to only appear in the good conversation (Messages are of course saved in the database in the right conversation).
  Thank you for your help !</p>