From 12064d8e5debf674cd5d367e563b699f10a4325e Mon Sep 17 00:00:00 2001 From: indexzero Date: Sun, 17 Apr 2011 03:25:48 -0400 Subject: [PATCH] [doc test] Small updates to README.md. Update to try require socket.io --- README.md | 4 ++-- examples/web-socket-proxy.js | 13 +++++++++++-- test/web-socket-proxy-test.js | 13 +++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 67f8421..3f41263 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ You have all the full flexibility of node-http-proxy offers in HTTPS as well as
   var fs = require('fs'),
       https = require('https'),
-      httpProxy = require('httpProxy');
+      httpProxy = require('http-proxy');
       
   var options = {
     https: {
@@ -265,7 +265,7 @@ You have all the full flexibility of node-http-proxy offers in HTTPS as well as
 Websockets are handled automatically when using the `httpProxy.createServer()`, but if you want to use it in conjunction with a stand-alone HTTP + WebSocket (such as [socket.io][5]) server here's how:
 
   var http = require('http'),
-      httpProxy = require('httpProxy');
+      httpProxy = require('http-proxy');
       
   //
   // Create an instance of node-http-proxy
diff --git a/examples/web-socket-proxy.js b/examples/web-socket-proxy.js
index a1cac4d..f31f300 100644
--- a/examples/web-socket-proxy.js
+++ b/examples/web-socket-proxy.js
@@ -26,11 +26,20 @@
 
 var sys = require('sys'),
     http = require('http'),
+    colors = require('colors'),
     websocket = require('./../vendor/websocket'),
-    utils = require('socket.io/lib/socket.io/utils'),
-    io = require('socket.io'),
     httpProxy = require('./../lib/node-http-proxy');
 
+try {
+  var utils = require('socket.io/lib/socket.io/utils'),
+      io = require('socket.io');  
+}
+catch (ex) {
+  console.error('Socket.io is required for this example:');
+  console.error('npm ' + 'install'.green + ' socket.io'.magenta);
+  process.exit(1);
+}
+
 //
 // Create the target HTTP server
 //
diff --git a/test/web-socket-proxy-test.js b/test/web-socket-proxy-test.js
index 9ba6e41..726f095 100644
--- a/test/web-socket-proxy-test.js
+++ b/test/web-socket-proxy-test.js
@@ -26,13 +26,22 @@
  
 var vows = require('vows'),
     util = require('util'),
+    colors = require('colors'),
     request = require('request'),
     assert = require('assert'),
-    io = require('socket.io'),
-    utils = require('socket.io/lib/socket.io/utils'),
     websocket = require('./../vendor/websocket'),
     helpers = require('./helpers');
 
+try {
+  var utils = require('socket.io/lib/socket.io/utils'),
+      io = require('socket.io');  
+}
+catch (ex) {
+  console.error('Socket.io is required for this test:');
+  console.error('npm ' + 'install'.green + ' socket.io'.magenta);
+  process.exit(1);
+}
+
 var runner = new helpers.TestRunner();
 
 vows.describe('node-http-proxy/websocket').addBatch({