title: Symfony and Socket.io
body: <p>I'm trying this bundle to make calls via node controller symfony
  <a href="https://github.com/bazo/tembo" rel="nofollow">https://github.com/bazo/tembo</a> </p>
  
  <p>but I had to add exceptions for use as Would indeed</p>
  
  <p>i want to call my function 'barno' in my node </p>
  
  <p>Node.js</p>
  
  <pre><code>var app = require('express')()
      , server = require('http').createServer(app)
      , io = require('socket.io').listen(server);
  
  server.listen(9001);
  
  io.sockets.on('connection', function (socket) {
      socket.emit('news', { hello: 'world' });
      socket.emit('news2', { hello: 'world2' });
  
  
      socket.on('message', function(data){
          socket.broadcast.emit('broadcast-action', data);
      });
  
      socket.on('barno', function(data) {
          console.dir(data);
          socket.emit('barno', {profilo_da_seguire: '100'});
  
      });
  });
  </code></pre>
  
  <p>my Controller </p>
  
  <pre><code>$client = new SocketIOClient('http://localhost:9001');
  
          $client-&gt;connect();
  
          //emit event
          $args = ['nome' =&gt; 'alessio'];
          $client-&gt;emit('barno', $args);
  
          $received = 'barno';
          $pippo = array();
          try {
              $client-&gt;listen(function($event, Message $message = null) use (&amp;$received, &amp;$pippo) {
                  if($message !== null) {
                      if ($message-&gt;getName() == $received) {
                     $gino = $message-&gt;getArgs();
                          if (!is_object($gino[0])) {
                              $args = json_decode(current($message-&gt;getArgs()));
                          }else{
                           $args = $message-&gt;getArgs();
                              $pippo[] = $args[0];
                          }
  
                          throw new \Exception('Load');
                      }
                      /*$message = sprintf('packet: %d, time: %f, heartbeats: %d', $args-&gt;packet, $args-&gt;time, $args-&gt;heartbeats);
                      writeDebug($message);*/
                  }
              });
          } catch (\RuntimeException $e) {
              echo $e-&gt;getMessage();
          } catch (\Exception $e) {
  
          }
  
          //var_dump($pippo);
  
          foreach ($pippo as $i =&gt; $pluto) {
              $pippo[$i]-&gt;nome= 'barno';
          }
  
          $client-&gt;disconnect(1);
  
  
          return array(
              'pippo' =&gt; $pippo
          );
      }
  </code></pre>
  
  <p>whit the Xdebug I see That
  When the code arrive here</p>
  
  <pre><code> if ($message-&gt;getName() == $received) 
  </code></pre>
  
  <p>I have these calls</p>
  
  <pre><code>$message-&gt;getName() = "news"
  $message-&gt;getName() = "news2"
  $message-&gt;getName() = "barno"
  </code></pre>
  
  <p>i want only call the function Barno, how can i do this?</p>
  
  <p>Than i add this </p>
  
  <pre><code>throw new \Exception('Load');
  </code></pre>
  
  <p>because the code entered in the loop</p>
  
  <p>the result is</p>
  
  <pre><code>    array (size=1)
    0 =&gt; 
      object(stdClass)[53]
        public 'profilo_da_seguire' =&gt; string '100' (length=3)
        public 'nome' =&gt; string 'barno' (length=5)
  </code></pre>
  
  <p>And this is correct but after unless calls</p>