1

I have googled this question quite often but am still a little confused as to whether what exactly I'm trying to do is possible or not.

Basically, I am trying to add a dropdown menu to my web application in which it lists all devices connected to the network. When I say devices, I'm not talking about all devices; I am talking about certain hardware devices that I am using in which SSDP is implemented. I have already created Node.js programs that send M-SEARCHes and successfully find all the devices but I understand that Node.js is not a browser javascript and there is no way I could display the output of a Node call in a terminal on a browser (please correct me if I am wrong).

After doing a bit more research into it, I realized that alternatives when doing something of this sort on a browser is to either create some sort of Chrome extension that is able to do SSDP and send M-searches, or to open websockets using a websocket API (don't think this is particularly useful in my case for SSDP but I may be wrong).

Given what I am trying to do, are either of these alternatives helpful. Is what I am trying to do even possible? Once again, I have done my research in this topic but I really haven't been able to find a clear answer. If it is possible, I'd really appreciate links to tutorials or just general ideas on how to accomplish what I am trying to do.

I know I posted something on StackOverflow recently about this, which got no answers or replies, but I have done more research into this topic and felt like I do have a better understanding. That being said, I'd still appreciate some direction as to how to approach this problem as I haven't found anything too useful online.

Thank you for your time!

trynacode
  • 361
  • 1
  • 8
  • 18

2 Answers2

1

Chrome extensions cannot access the sockets.udp API as far as I know. The right place to do that in Chrome would probably have been a Chrome App, as they can do UDP Multicast: https://codereview.chromium.org/12684008/ . In fact there seems to be an SSDP app already ...

Unfortunately Chrome Apps have been deprecated in favor of normal web apps (outside of Chrome OS at least), and as you've found out you can't do SSDP through normal web APIs yet. The socket API is under works but there's no telling if and when they might solve the security problems inherent in allowing a random web app to do things like join a local multicast group.

Websockets are unlikely to provide what you need.

Jussi Kukkonen
  • 13,857
  • 1
  • 37
  • 54
  • Thanks for the answer! So essentially, it is impossible for me to do what I am trying to do, at least within Chrome? It could be possible in say another browser such as Mozilla Firefox? – trynacode Sep 07 '16 at 17:13
  • 1
    It is possible with a chrome app, it's just that very soon you can't get new apps into the store anymore and in a year or two the whole store will close (except for Chrome OS). Doing this as an extension in Mozilla may be possible but I'm guessing it'll be tricky as well: This is just not something browsers are capable of yet. If you really want to show SSDP results in browser, I think you should make and run a Web service (a server) that provides this info to your Web app. Of course at that point the whole purpose of a Web app is questionable... – Jussi Kukkonen Sep 08 '16 at 06:07
  • Great, thank you for the information. I am already communicating with a REST API so maybe I can try to add SSDP information to that API. Thanks. – trynacode Sep 08 '16 at 18:27
0

Its possible.

Node.js is not a browser javascript and there is no way I could display the output of a Node call in a terminal on a browser

They both run Javascript. Run your nodjs in a terminal or pipe the output to a text file if terminal is not accessible. in both cases console.log() should be able to print out.

For SSDP on client and server side, use this : https://www.npmjs.com/package/node-ssdp

You need not use a Chrome app specically. You can write apps in Javascript based cross platform frameworks like Electron. Itll become a fully functional 'web'-app for PCs and for mobiles you can use Cordova and the likes.

Kevin Roy
  • 111
  • 8