-1

I wish to create a Cordova/Android app that will be called/executed from my server. Both devices are on the same intranet and connect via WiFi, therefore no cloud messaging required . For another scenario I have done the opposite. i.e. Android calls, via Ajax, an application on a Raspberry Pi for door opening purposes but this time I want to call an Android application from a Raspberry Pi. Where do I start? Ajax? Socket Server? What is the recommended connection method?

Straygrey
  • 5
  • 1
  • 3

1 Answers1

0

I think that websockets are the way to go. Implementing such a real time application allows you to 'push' data from the server to connected clients.

This can be initiated by clients (like in a chat application) but also by the server based on whatever events.

Have a look at Primus as a possible implementation. It abstracts the functionality from the websockets layer. This way it is possible to work with different websocket implementations.

Andre Kreienbring
  • 2,457
  • 11
  • 16
  • To make my story a little more complicated, after being called, I want the Android application to take a photograph and send that back to the server, then wait for next call. I thought Ajax might serve the purpose. – Straygrey Oct 29 '15 at 13:37
  • Thats perfectly possible with websockets. As soon as data arrives from the server it can be interpreted and reacted upon. Messages (e.g) as JSON objects) can be send back and forth. – Andre Kreienbring Oct 29 '15 at 13:42
  • I have created a websocket application but when I attempt to connect to it from another device I get "connection refused". – Straygrey Oct 30 '15 at 06:14
  • BTW My app is based on what I found at http://stackoverflow.com/questions/25464614/using-socket-io-with-cordova-and-ios-device – Straygrey Oct 30 '15 at 06:17
  • I have attempted doing something similar but I get "connection refused" when I attempt connecting from my server? – Straygrey Oct 30 '15 at 06:19
  • Be sure that your connection is initiated by the client. After the connection was established the server may send information to the connected clients. And please accept this answer if it helped you to help other developers who are facing the same problem. – Andre Kreienbring Nov 02 '15 at 11:44