summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges-Etienne Legendre <legege@legege.com>2013-06-28 20:21:19 (GMT)
committerGeorges-Etienne Legendre <legege@legege.com>2013-06-28 20:21:19 (GMT)
commitf8b18bfe54845c7088e01d35b4815f5fe2b1a0b6 (patch)
treee42e166d8a0a110f4890ef254434fbd347d62690
parentd6d0b647516da8fda66258cceef633c7a51f8971 (diff)
Fixing a issue with response socket being null, now using the request socket for close event watching
-rw-r--r--example/express-app.js3
-rw-r--r--mjpeg-proxy.js3
2 files changed, 4 insertions, 2 deletions
diff --git a/example/express-app.js b/example/express-app.js
index 558708d..be2b7de 100644
--- a/example/express-app.js
+++ b/example/express-app.js
@@ -22,6 +22,7 @@
var MjpegProxy = require('../mjpeg-proxy').MjpegProxy;
var express = require('express');
var app = express();
+
var HTTP_PORT = 8080;
var cam1 = "http://admin:admin@192.168.124.54/cgi/mjpg/mjpg.cgi";
@@ -35,4 +36,4 @@ app.get('/index2.jpg', new MjpegProxy(cam2).proxyRequest);
app.listen(HTTP_PORT);
-console.log("Listening on port "+HTTP_PORT);
+console.log("Listening on port " + HTTP_PORT); \ No newline at end of file
diff --git a/mjpeg-proxy.js b/mjpeg-proxy.js
index e7989d4..0802497 100644
--- a/mjpeg-proxy.js
+++ b/mjpeg-proxy.js
@@ -57,6 +57,7 @@ var MjpegProxy = exports.MjpegProxy = function(mjpegUrl) {
} else {
// Send source MJPEG request
var mjpegRequest = http.request(self.mjpegOptions, function(mjpegResponse) {
+ // console.log('request');
self.globalMjpegResponse = mjpegResponse;
self.boundary = extractBoundary(mjpegResponse.headers['content-type']);
@@ -126,7 +127,7 @@ var MjpegProxy = exports.MjpegProxy = function(mjpegUrl) {
self.audienceResponses.push(res);
self.newAudienceResponses.push(res);
- res.socket.on('close', function () {
+ req.socket.on('close', function () {
// console.log('exiting client!');
self.audienceResponses.splice(self.audienceResponses.indexOf(res), 1);