title: TypeError: io.sockets.clients is not a function
body: <p>I am following the tutorial at this <a href="https://bitbucket.org/webrtc/codelab" rel="noreferrer">link</a> (step 7).
  I successfully installed both node.js either socket.js , but when i go to the page and try to send the image i get this error on the server</p>
  
  <pre><code>Missing error handler on `socket`.
  TypeError: io.sockets.clients is not a function
  at Socket.&lt;anonymous&gt; (C:\Users\utente\Projects\webrtc\server.js:30:31)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:169:7)
  at Socket.onevent (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\socket.js:330:8)
  at Socket.onpacket (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\socket.js:290:12)
  at Client.ondecoded (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\client.js:193:14)
  at Decoder.Emitter.emit (C:\Users\utente\Projects\webrtc\node_modules\socket.io\node_modules\socket.io-parser\node_modules\component-emitter\index.js:134:20)
  at Decoder.add (C:\Users\utente\Projects\webrtc\node_modules\socket.io\node_modules\socket.io-parser\index.js:247:12)
  at Client.ondata (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\client.js:175:18)
  at emitOne (events.js:77:13)
  </code></pre>
  
  <p>my server.js file is</p>
  
  <pre><code>var os = require('os');
  var static = require('node-static');
  var http = require('http');
  var socketIO = require('socket.io');
  
  var fileServer = new(static.Server)();
  var app = http.createServer(function (req, res) {
  fileServer.serve(req, res);
  }).listen(2013);
  
  var io = socketIO.listen(app);
  io.sockets.on('connection', function (socket){
  
  // convenience function to log server messages on the client
  function log(){
      var array = ["&gt;&gt;&gt; Message from server:"];
      array.push.apply(array, arguments);
      socket.emit('log', array);
  }
  
  socket.on('message', function (message) {
      log('Client said:', message);
      // for a real app, would be room only (not broadcast)
      socket.broadcast.emit('message', message);
  });
  
  socket.on('create or join', function (room) {
      log('Request to create or join room ' + room);
  
      var numClients = io.sockets.clients(room).length;
      log('Room ' + room + ' has ' + numClients + ' client(s)');
  
      if (numClients === 0){
          socket.join(room);
          socket.emit('created', room, socket.id);
  
      } else if (numClients === 1) {
          socket.join(room);
          socket.emit('joined', room, socket.id);
          io.sockets.in(room).emit('ready');
  
      } else { // max two clients
          socket.emit('full', room);
      }
  });
  
  socket.on('ipaddr', function () {
      var ifaces = os.networkInterfaces();
      for (var dev in ifaces) {
          ifaces[dev].forEach(function (details) {
              if (details.family=='IPv4' &amp;&amp; details.address != '127.0.0.1') {
                  socket.emit('ipaddr', details.address);
              }
        });
      }
     });
  
  });
  </code></pre>
  
  <p>the index.html is</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name="keywords" content="JavaScript, WebRTC" /&gt;
      &lt;meta name="description" content="WebRTC codelab" /&gt;
      &lt;meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"&gt;
  
      &lt;title&gt;WebRTC codelab: step X&lt;/title&gt;
      &lt;link rel="stylesheet" href="css/main.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;WebRTC codelab: step X&lt;/h1&gt;
  
      &lt;p&gt;
          Room URL: &lt;br&gt;
          &lt;code id="url"&gt;...&lt;/code&gt;
      &lt;/p&gt;
  
      &lt;video class="camera" autoplay&gt;&lt;/video&gt;
      &lt;div class="controls"&gt;
          &lt;canvas id="photo" style="width: 200px; height: 150px; border: 1px solid #ccc;"&gt;&lt;/canvas&gt;
          &lt;p&gt;
              &lt;button id="snap"&gt;snap&lt;/button&gt;-then-&lt;button id="send"&gt;send&lt;/button&gt; 
              &lt;br&gt; - or - &lt;br&gt;
              &lt;button id="snapAndSend"&gt;snap &amp; send&lt;/button&gt;
          &lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div class="incoming"&gt;
          &lt;h2&gt;Incoming photos&lt;/h2&gt;
          &lt;div id="trail"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;script src="node_modules\socket.io\node_modules\socket.io-client\socket.io.js"&gt;&lt;/script&gt;
      &lt;script src="js/lib/adapter.js"&gt;&lt;/script&gt;
      &lt;script src="js/main.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>any help?</p>
  
  <p>thanks a lot</p>
  
  <p>with io.sockets.clients[room].length; i solved the error but now i get</p>
  
  <pre><code>Missing error handler on `socket`.
  TypeError: Cannot read property '8a675bfe1203e' of undefined
  at Socket.&lt;anonymous&gt; (C:\Users\utente\Projects\webrtc\server.js:30:38)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:169:7)
  at Socket.onevent (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\socket.js:330:8)
  at Socket.onpacket (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\socket.js:290:12)
  at Client.ondecoded (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\client.js:193:14)
  at Decoder.Emitter.emit (C:\Users\utente\Projects\webrtc\node_modules\socket.io\node_modules\socket.io-parser\node_modules\component-emitter\index.js:134:20)
  at Decoder.add (C:\Users\utente\Projects\webrtc\node_modules\socket.io\node_modules\socket.io-parser\index.js:247:12)
  at Client.ondata (C:\Users\utente\Projects\webrtc\node_modules\socket.io\lib\client.js:175:18)
  at emitOne (events.js:77:13)
  </code></pre>