How to create sockets in google chrome extension? - google-chrome-extension

I created small hello world extension for google chrome http://code.google.com/chrome/extensions/getstarted.html. I need to use sockets in extension for peer to peer communication using UDP. Is there any firefox Jslib equivalent in google chrome or how we can use other languages in google chrome extension?
I doubt its possible in google chrome, looking at its documentation. ? Are there any other ways to achieve p2p communication in extension?

Chrome has an packaged app support for raw socket connections. More general info here. This used to be available to extensions as well but it's not clear if that's still true.
The documentation indicates that only UDP is available for the type when the socket is created. However, recently (Jan 2012) there was a commit adding TCP support.

These are not websockets (it's TCP or UDP sockets):
http://developer.chrome.com/apps/socket.html
https://developers.google.com/live/shows/7320022-5001
The second link is a howto for making a web-server in a Chrome app.

Related

Is it possible to connect to Sony Camera Remote API with hybrid mobile apps

Since we need to have a UDP socket to discover the device, and since javascript seems not supporting UDP, is it possible to connect to Sony Camera Remote API with a javascript based mobile app (non native).
As said in the comments, you can use Cordova to do the SSDP discovery.
However, as far as I can see, the API is HTTP-based. So if you don't need discover (can write in the IP address and port manually), then this should be possible to do.
Did you ever get anywhere with this project? I'd be interested in getting some LiveView and controlling a camera using Javascript.

Communicating with nearby devices

I want to develop a FirefoxOS privileged app that can send text messages to nearby devices.
Android app can use Bluetooth or Wifi P2P. But FirefoxOS privileged apps cannot use Bluetooth/Wifi API. These are only available for certified apps.
Privileged apps can use TCP socket API. Is this the only way?
Is there any way to get available IP addresses on LAN?
#Kazhik, unfortunately right now, that is the only way to go. And the explanation for that is that by using the socket API you can implement any protocol on top of TCP, such as IMAP, IRC, POP, HTTP, etc., or even build your own to sustain any specific needs you could have.
Since certified apps can only be included by the oem, access to Bluetooth or WiFi information API aren't a viable option now.
At today's date (September 18, 2015) the WebIDE supports installing certified apps in older Firefox OS versions like 1.3 and in physical devices.
I tried installing the Gaia test apps (these are certified) in one Alcatel OT FireC and everything worked perfectly fine ;)
DNS-SD (part of the Zeroconf specification) allows you to broadcast and receive "advertisements" from other devices on the local network. That requires UDP and TCP permissions, which means a "privileged" app, as you thought. That's not a problem, unless you need to distribute the app outside of the Firefox Marketplace.
There's an implementation of DNS-SD for JavaScript at https://github.com/justindarc/dns-sd.js
For compatibility with other messaging apps, you might want to implement XMPP:
http://www.xmpp.org/extensions/xep-0174.html

Chrome/firefox extension to read data streaming over USB and network to localhost

I'm looking at the possibility of using a chrome extension or firefox addon that will allow me to read information that is sent over USB in the form of text data? And to the localhost/IP of the machine to certain port?
Can someone point me to the any examples or API documents that will help with my search?
The idea be that the extension is listening for text data on USB or to the localhost of the machine.
Thanks in advance
Additional information:
Can an extension listen to traffic being set over a local IP? on a certain port? Can it be sent to localhost?
Can you listen to data being sent over a USB port?
There is chrome.usb for interacting with USB devices. It is only accessible in Chrome apps however and not extensions.
In Chrome the browser will not provide such access to the system.
The correct way would be to have an external program collecting the data and communicating with the browser add-on. It is achieved through Native Messaging.
Note that you will not be able to bundle the external program with the extension; you'll need to have your own installer.
Edit: I have to comment that #abraham's answer is perhaps more correct. You can have raw USB access in a context of a Packaged App.

Build own Chromecast device

The Chromecast device is a "receiver device [that] runs a scaled-down Chrome browser with a receiver application". Can I download and install this receiver app on a chrome browser for example on my Windows notebook?
I have implemented a complete chromecast v2 receiver, called YouMap ChromeCast Receiver, available in Google play store and Amazon store, xda-developer thread here: http://forum.xda-developers.com/android-tv/chromecast/app-youmap-chromecast-receiver-android-t3161851
The current Chromecast protocol is a completely different one from the original DIAL based protocol. Right now, only YouTube still uses the old protocol, which chromecast maintains its backward compatibility.
The discovery is mDNS, exactly same as Apple TV bonjour protocol.
The most difficult part is device authentication, the sender and the receiver perform handshakes by exchanging keys and certificates in a way extremely difficult to crack. AppleTV does the same using FairPlay encryption.
The next difficult part is the mirroring protocol, which is also very complicated, need to deal with packet splits, packet retransmissions. Overall, chromecast mirroring protocol is well designed, better than miracast, better than AirPlay mirroring (I have also implemented both of them, so I know what I am talking about).
When I get chances, will write more here.
The chromecast device works using the DIAL protocol. It is completely possible to emulate this protocol using some simple code to listen on the multicast group for discovery and then handle the HTTP requests to launch applications. It is then the launched application that communicates with the casting device, I believe using the RAMP protocol.
Luckily for us the applications that the chromecast device uses are mostly web applications meaning our device emulator just needs to launch a web browser and point it to a specific url when it receives an application request.
For example the youtube app, after device discovery and establishing where the applications are located (part of DIAL). Will send a HTTP POST request containing a pairing key to /<apps url>/YouTube. All the emulating device needs to do now is open https://www.youtube.com/tv?<pairing key> in a browser window. From here, I believe, communication for controlling the youtube app is not sent through the casting device but through the open tabs on the casting device and the emulator.
This is my understanding of how the chromecast device works and specifically the youtube app from looking at https://github.com/dz0ny/leapcast which is a python emulator that has youtube and google music working.
Google is in progress of open sourcing some part of the chrome cast.
https://code.google.com/p/chromium/codesearch#chromium/src/chromecast/
https://code.google.com/p/chromium/issues/list?q=label:Chromecast
So theoretically you can build a similar device.

Videoconferencing server on linux

I need to implement a one-to-one videoconferencing solution server-based, runnable by browser, free (or not expensive), ssl support and good quality video and audio. What would you advise me?
See WebRTC. Chrome and Firefox will be supporting it (early support is in Chrome now, soon will be in Firefox). It appears Microsoft will be supporting it too - they're hiring engineers specifically for WebRTC work.

Resources