Help with android to chrome communication - javascript

I have been working on creating an application that sends a string from an android phone to a server and from there sending it to a Chrome extension. I am sitting with a few options to continue, I can convert everything to websockets, I can use normal sockets for android to computer and websockets for extension to server, or I can do some HTTPRequest stuff.
I am looking for suggestions on the best way to pull off this communication. I have a php server an android application and a chrome extension that need to be connected. If there is a way to connect the android application to the chrome extension without the server I would be happy to hear that too.
I need something secure and something that can be organized based on the correct person asking or sending information. So when someone sends a string from the android application the server stores it (probably using their gmail) and when the extension asks for it the server sends it along.
Also could the server just push the string to the extension without the extension calling it? This would occur after the initial websocket connection. I guess it would just store the IP address or something like that.
Any suggestions or comments would be appreciated I am just trying to make the most efficient and secure system I can come up with. I have done a significant amount of research about every aspect so I'm more suffering from information overload then anything.
Thanks in advance :]

Look into Windows Communication Foundation Services (WCF). That's what I have been using for my android applications working with a database - the .NET framework is great, and the services seem to be fairly dynamic.
http://msdn.microsoft.com/en-us/netframework/aa663324

Related

Need to send ASCII string from website to PC via UDP

I'm looking for some ideas on how to approach this challenege.
I have a tablet that I'm using as a remote control to trigger software on a PC.
The trigger is an ASCII string that has to be sent via UDP.
The network is closed, no protection or security enabled. The server has a static IP.
I've built the website and created all the functions but haven't found a great way to actually send the text from the website to the PC.
I'm thinking that node.js -- which I have no experience with -- is the only way to do this but I'd appreciate some other thoughts.
Thanks.
Dave

Webapp and notification

Which is the best way to notify a webapp (need to work in chrome and safari) from server? (my webapp is in angular for information).
Is it possible to receive UDP broacast with a webapp? (If not, that will not be a problem i can do a little app that will receive the broadcast and translate it to a notification but which is the best one for webapp that the question...)
This probably a double post but i didn't find a real example so if you can give me an example of what i need to do that gona be great :).
I'm not sure of what you want, but if you need to notify your webapp from server in real time you probably will be interested by websocket technology. You can get information about this subject here: https://developer.mozilla.org/fr/docs/WebSockets
If you use a nodeJs server, socket.io seems to be great and there are good exemples and documentation in the official website (http://socket.io/).

Modbus TCP communication from HTML/Javascript Webpage

I have a device that uses Modbus TCP. I want to read data from it and display it on a webpage (Without an in between server).
I have found a project that does almost this exact same thing as a Chrome extension:
https://github.com/Cloud-Automation/chrome-modbus
It uses this in the javascript code: chrome.sockets.tcp
I was hoping that I could do the same thing on my webpage using WebSockets.
It seems that websockets would work on my webpage (acting as the client), sending and receiving information from the device (acting as the server). It doesn't seem that websockets is affected by cors.
Does anybody have pointers on where I could start on this? (Or a javascript library would be great)
Is this possible?
Without an in between server will not be possible, unless your plc supports other protocol different than modbus (e.g. post/get).
If your plc is "completely closed" and you only have this port/protocol open, then you need an in between server that makes the conversion of modbus tcp to html. Using node-red as well as the dashboard and modbus flows, you can achieve it.
If you solved it other way, I would like to know how you did it.
I did get this solved without a server in between. I did it using Chrome Sockets link I also made it work using a cordova app for smart phones. Firefox has a sockets api as well, but did not attempt to figure it out for that browser.
I solve this using the PLC Connect in vb, i used vb to pass data in database and get the data through javascript.

Getting basic information of devices that is connected to network

Base of my question: I am trying to create a simple code that can list basic information of a device that is connected to a network. For example, I have a wireless router, and there is a device(Mobile Phone) connected via wireless connection, and a device(Laptop/Desktop) that is connected via LAN. Now I want to find out what kind of device it is, also: the IP address, MAC address, processor, RAM, HDD/Internal Storage, Flash Drive(if connected) and let's say hardware manufacturer (If possible) etc..
Now I already have searched for these, and I found that this can be done by .NET, but I am thinking that this would be better if I can access this via web so even I'm at the office/work I can check the devices that are connected to our network. So I decided to do this using PHP, but don't know how to begin because I only have little knowledge of PHP, anyone can give me a sample of what I am tryng to achieve? Or any better reference on getting information of connected device on network via PHP?
PHP is a server side scripting language.
It will not allow you to enumerate connected devices due to security reasons.
Take a look at PHP with NMAP:
https://nmap.org/
Some examples to look at:
How to use Nmap in PHP exec
PHP trim nmap MAC address

peer to peer communication between mobile app and pc browser

I am working on a project where i need my mobile application to talk to my web browser on a pc, where both devices are connected over wifi. The app would send data which would be received by the computer browser followed by some client side code execution. The browser then may send some feedback.
My initial approach is to make the app talk to an endpoint which in turn talks to client side of the browser (javascript).
What could be the best approach to do this ?
Update
I am not sure if Socket.io is a possible solution since it requires a server to be hosted. Is it possible to solve this using sockets ?
You've now edited your question to mention P2P. That's quite hard to achieve PHONE TO BROWSER (i.e., by hard I mean 6 to 12 man-months of work - and/or plain not possible). However in MOST situations you can instantly (ie "one line of code on each platform") resolve the problem by using a service like pubnub. Much as nobody has back-ends anymore and everything is just done with parse.com or game center, networking like you mention is now just done with pubunb (or any competitor).
This is an extremely common use case problem - and everyone just uses PubNub as mentioned below or one of its competitors.
These days it couldn't be easier, just use pubnub.com
It's the world's biggest data-messaging service for a reason!
There's essentially no other realistic approach, it's so simple - a few lines of code.
So short answer would be: A real peer-to-peer (P2P) communication is currently not possible with all browsers. So instead you have the following options:
App + Server with a WebUI (maybe)
App + Chrome App (Chrome Apps can start an web server, see http://www.devworx.in/news/misc/chrome-apps-can-now-run-a-web-server-135711.html)
App + WebApp with Plugin (Flash, Silverlight or Java)
I personally would prefer solution 1.
You need a server. If you consider this problem strictly from the typical firewall point of view, a PC or a mobile device are going to ignore connections unless they initiate the connection themselves. So neither the PC nor the mobile device can start a connection with the other.
My understanding is that web browsers do not support standard sockets within javascript. You can use the analagous websocket, but sockets and websockets are not directly compatible.
You can setup a simple server on the PC, and have this server relay messages between the mobile device and the PC browser. Both the mobile device and the PC browser connect to the server. This is basically what an external service will do for you.
PeerJS is what you're looking for:
http://peerjs.com

Categories

Resources