docs: function connect(connector){
      return connector.connect().then(function() {
      	// Set time
      	date = new Date();
  
          // If we are here, we are connected
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Connected to: '+ connector.endpoint.host +'</p>');
      	
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to errors</p>');
  
          // Subscribe to errors channel
          nem.com.websockets.subscribe.errors(connector, function(res){
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received error</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to new blocks</p>');
  
          // Subscribe to new blocks channel
          nem.com.websockets.subscribe.chain.blocks(connector, function(res){
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received a new block</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to recent transactions</p>');
  
          // Subscribe to recent transactions channel
          nem.com.websockets.subscribe.account.transactions.recent(connector, function(res){
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received recent transactions</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to account data of '+ connector.address +'</p>');
  
          // Subscribe to account data channel
          nem.com.websockets.subscribe.account.data(connector, function(res) {
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received account data</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to unconfirmed transactions of '+ connector.address +'</p>');
  
          // Subscribe to unconfirmed transactions channel
          nem.com.websockets.subscribe.account.transactions.unconfirmed(connector, function(res) {
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received unconfirmed transaction</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Subscribing to confirmed transactions of '+ connector.address +'</p>');
  
          // Subscribe to confirmed transactions channel
          nem.com.websockets.subscribe.account.transactions.confirmed(connector, function(res) {
              // Set time
              date = new Date();
              // Show event
              $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Received confirmed transaction</p>');
              // Show data
              $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(res) +'</pre>');
          });
          
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Requesting account data of '+ connector.address +'</p>');
  
          // Request account data
          nem.com.websockets.requests.account.data(connector);
  
          // Show event
      	$('#stream').append('<p><b>'+ date.toLocaleString()+':</b> Requesting recent transactions of '+ connector.address +'</p>');
          
          // Request recent transactions
          nem.com.websockets.requests.account.transactions.recent(connector);
  
      }, function(err) {
          // Set time
          date = new Date();
          // Show event
          $('#stream').append('<p><b>'+ date.toLocaleString()+':</b> An error occured</p>');
          // Show data
          $('#stream').append('<p><b>'+ date.toLocaleString()+': <pre>' + JSON.stringify(err) +'</pre>');
          // Try to reconnect
          reconnect();
      });
  }