kensakukomatsu / chrome-upnp Goto Github PK
View Code? Open in Web Editor NEWit enables upnp m-search in chrome extensions (it utilizing experimental raw socket api)
it enables upnp m-search in chrome extensions (it utilizing experimental raw socket api)
after implementing whitelist-xhr, trying to control over SOAP will be necessary.
Opera's sample code is helpful.
http://people.opera.com/richt/release/specs/discovery/Overview.html
function successCallback( services ) {
// Listen for service push messages
services[0].addEventListener('message', function ( msg ) {
debug.innerHTML += "<br>" + services[0].name + " event received: ";
debug.textContent += msg.data;
}, false);
// Send a control signal to mute the service audio
var svcXhr = new XMLHttpRequest();
svcXhr.open("POST", services[0].url); // services[0].url and its
// subresources have been whitelisted for
// cross-site XHR use in this current
// browsing context.
svcXhr.setRequestHeader('SOAPAction', 'urn:schemas-upnp-org:service:RenderingControl:1#SetMute');
svcXhr.setRequestHeader('Content-Type', 'text/xml; charset="utf-8";');
svcXhr.onreadystatechange = function ( response ) {
if( response.readyState != 4 || response.status != 200 )
return;
debug.innerHTML += "<br>" + services[0].name + " response received: ";
debug.textContent += response.responseXML;
}
// Service messaging to mute the provided service
var svcMsg = '<?xml version="1.0" encoding="utf-8"?>' +
'<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ' +
'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' +
'<s:Body>' +
'<u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">' +
'<InstanceID>0</InstanceID>' +
'<Channel>Master</Channel>' +
'<DesiredMute>true</DesiredMute>' +
'</u:SetMute>' +
'</s:Body>' +
'</s:Envelope>';
svcXhr.send(svcMsg);
debug.innerHTML += "<br>" + services[0].name + " request sent: ";
debug.textContent += svcMsg;
}
function errorCallback( error ) {
debug.innerHTML += "<br>An error occurred: " + error.code;
}
To obtain description.xml and do control with SOAP, shim has to support white-list xhr.
In the web apps level, indicating "http://*/" in permissions property is enough. So interface from shim to content_script page have to be implemented.
In the WebIntents-TF ML, Paul mentioned that chrome.socket works only Chrome Apps.
"Just a quick note, it is not intended for the raw sockets API to be available to extensions. Only the new form Chrome Apps, so this might explain why it is not working for you."
So, trying UPnP shim on web apps
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.