Skip to content

Commit

Permalink
Suggested implementation for option 2 described in fraunhoferfokus#2
Browse files Browse the repository at this point in the history
  • Loading branch information
mwittig committed Jan 12, 2017
1 parent 3cb16ef commit cc7d245
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/peer-upnp.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ var createPeer = function(options){
var Peer = function(options){
var self = this;
this.prefix = options.prefix || "";
this.iconPath = options.iconPath || "/icons";
if (this.iconPath.indexOf('/') === 0) {
this.iconPathPrefix = this.iconPath;
}
else {
this.iconPathPrefix = (this.prefix + "/device/" + this.iconPath).replace(/\/{2,}/, '/');
}
this.server = options.server || null;
this.hostname = options.hostname || getHostname();
this.port = options.port || (this.server && this.server.address() && this.server.address().port);
Expand Down Expand Up @@ -623,6 +630,9 @@ var registerHTTPHandler = function(peer){
if (req) {
var url = URL.parse(req.url,true);
var method = req.method.toUpperCase();
if (url.pathname.indexOf(peer.iconPathPrefix) == 0) {
peer.emit("iconRequest", url.pathname.substring(url.pathname.indexOf(peer.iconPath)), rsp)
}
var isPeer = url.pathname.indexOf(peer.prefix) == 0;
}
else {
Expand Down

0 comments on commit cc7d245

Please sign in to comment.