Skip to content

Commit

Permalink
[examples] Updated examples to v0.7.x API.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu committed Sep 21, 2011
1 parent 24ef919 commit 8fc8d96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
16 changes: 7 additions & 9 deletions examples/websocket/latent-websocket-proxy.js
Expand Up @@ -67,12 +67,14 @@ socket.on('connection', function (client) {
//
// Setup our server to proxy standard HTTP requests
//
var proxy = new httpProxy.HttpProxy();
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res, {
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8080
})
}
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
});

//
Expand All @@ -83,11 +85,7 @@ proxyServer.on('upgrade', function (req, socket, head) {
var buffer = httpProxy.buffer(socket);

setTimeout(function () {
proxy.proxyWebSocketRequest(req, socket, head, {
port: 8080,
host: 'localhost',
buffer: buffer
});
proxy.proxyWebSocketRequest(req, socket, head, buffer);
}, 1000);
});

Expand Down
15 changes: 7 additions & 8 deletions examples/websocket/standalone-websocket-proxy.js
Expand Up @@ -67,23 +67,22 @@ socket.on('connection', function (client) {
//
// Setup our server to proxy standard HTTP requests
//
var proxy = new httpProxy.HttpProxy();
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res, {
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 8080
})
}
});
var proxyServer = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
});

//
// Listen to the `upgrade` event and proxy the
// WebSocket requests as well.
//
proxyServer.on('upgrade', function (req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head, {
port: 8080,
host: 'localhost'
});
proxy.proxyWebSocketRequest(req, socket, head);
});

proxyServer.listen(8081);
Expand Down

0 comments on commit 8fc8d96

Please sign in to comment.