Skip to content

Commit

Permalink
Added ipaddress/domain name as param
Browse files Browse the repository at this point in the history
  • Loading branch information
kiriapurv committed Nov 13, 2014
1 parent 16aee6c commit 0980a9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Access and stream web cam in nodejs using opencv and web sockets.
#### Usage

```
npm start -- [-open] [-wsport websocketPort] [-webport webserverport]
npm start -- [-open] [-wsport websocketPort] [-webport webserverport] [-ip ipaddress/domain]
```

| Option | Description |
|---|---|
|-open | Open streaming url on startup |
|-wsport | Web socket port for streaming media |
|-webport | Web server port |
|-ip | Domain name/ip for non-localhost clients |
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
};

function openCamera() {
ws = new WebSocket("ws://localhost:##wsport");
ws = new WebSocket("ws://##webSocketAddress");
var sizeReceived = false;
ws.onopen = function () {
ws.send("open");
Expand Down
9 changes: 7 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var cam = require("../build/Release/camera.node");
var fs = require("fs");
var websocketPort = 9090,
webPort = 9999,
openBrowser = false;
openBrowser = false,
ip = "localhost";

//Gathering Arguments
process.argv.forEach(function (val, index, array) {
Expand All @@ -17,6 +18,10 @@ process.argv.forEach(function (val, index, array) {
case "-webport":
webPort = parseInt(array[index + 1]);
break;
case "-ip":
ip = array[index + 1];
break;

}
});

Expand Down Expand Up @@ -99,7 +104,7 @@ wss.on('connection', function (ws) {

//Create Http Server
var http = require("http");
var index = fs.readFileSync(__dirname + "/../index.html", 'utf8').replace("##wsport", websocketPort);
var index = fs.readFileSync(__dirname + "/../index.html", 'utf8').replace("##webSocketAddress", ip + ":" + websocketPort);
http.createServer(function (req, resp) {
resp.writeHead(200, {
"Content-Type": "text/html"
Expand Down

0 comments on commit 0980a9b

Please sign in to comment.