title: Socket.IO clients to receive offline messages when coming back
body: <h3>Environment:</h3>
  
  <p>Nodejs+Socketio</p>
  
  <h3>Problem:</h3>
  
  <ol>
  <li>client A and client B both connect to server;</li>
  <li>client B is offline;</li>
  <li>client A sends a message to client B(client B still offline);</li>
  <li>client B connect to server again;</li>
  <li>[<strong>Problem</strong>] client B can't receive the message from A;</li>
  </ol>
  
  <h3>Server Code</h3>
  
  <pre><code>var clients = {};
  io.sockets.on('connection', function (socket) {
  socket.on('online', function (data) {
      if (!clients[data.username]) {
          clients[data.username] = socket;
      }
      io.sockets.emit('message',  data.user + 'online now');
  });
  socket.on('say', function (data) {
      if (data.to == 'all') {
          io.sockets.emit('message', data.message);
      } else { //to specific client
          clients[data.to].emit('message', data.message);
      }
  });
  });
  </code></pre>
  
  <h3>Description</h3>
  
  <p>client B connected to server at one place first.During the period of client B's offline, client A sent messages to client B. Then client B connect to server at another place again,  and client B needs to receive those message from client A.  How to make it work?</p>