Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Had a very similar issue couple of days back and looks like socket.io had some changes in the API. I have never worked with symfony and am hoping the issues are the same.</p> <p>I have a working demo of socket.io sending and receiving a message - uploaded to <a href="https://github.com/parj/node-websocket-demo" rel="nofollow">https://github.com/parj/node-websocket-demo</a> as a reference</p> <p>Essentially two changes</p> <ol> <li><p>On Server side - changed <code>socket.on</code> to <code>socket.sockets.on</code> </p> <pre><code>var socket = io.listen(server); socket.sockets.on('connection', function(client) </code></pre></li> <li><p>On Client side - URL and port not required as it is autodetected.</p> <pre><code>var socket = io.connect(); </code></pre></li> </ol> <p>This has been tested using Express 2.5.2 and Socket.io 0.8.7</p> <p>I have amalgamated your server code with mine, would you be able to try this on the server and my <a href="https://github.com/parj/node-websocket-demo/blob/master/public/main.js" rel="nofollow">client javascript</a> and <a href="https://github.com/parj/node-websocket-demo/blob/master/public/index.html" rel="nofollow">client html</a> just to see if it is working?</p> <pre><code>var socket = io.listen(server); socket.sockets.on('connection', function(client){ var connected = true; client.on('message', function(m){ sys.log('Message received: '+m); }); client.on('disconnect', function(){ connected = false; }); var t = setInterval(function(){ if (!connected) { return; } cp.exec('/usr/bin/php /Users/crear/Projects/MandaFree/symfony api:getRemainingMessages', function(err, stdout){ if (err) { client.send('error : An error ocurred while running child process.'); } else { client.send('change : ' + stdout); } console.log('Remaining messages: ' + stdout); }); }, 3000); t(); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload