Amir Dadgari
Amir Dadgari

Reputation: 551

How to deploy a connection between two android devices using php host/server

I'm trying to send continuous data (like location) from android device A to android device B .

Right now android device A sends data to server and server saves data inside database and then device B reads data from server continuously.

1- Is there any way to connect this devices directly or in a way that there is less load on server?

2 Or a way to tell device B to wait until there is new data on server?

3 if I should use push notification for second question can I make a push notification server of my own and not use google cloud messaging?

4 how does messaging apps like Whatsapp and telegram handle sending data from one phone to another?

Upvotes: 1

Views: 138

Answers (1)

tremor
tremor

Reputation: 3186

Well there are two possibilities that you could go with, the first would be to simply setup a long-polling or websocket connection from Device B to the server, instead of reading the direct data continuously with a new connection each time, you maintain a connection to the server and when new data comes in, the server sends it to you. For more information about this - checkout out this stack Q&A: What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

The other possibility would be to use push notifications via any number of push services. Personally I like to use the If This Then That (IFTTT) https://ifttt.com maker channel. This is good if it is a personal project, but if you're developing something for an app that you will distribute or as a commercial product you might want to look at some of the paid options. I've also heard that https://pushbots.com/ provides a good service but I haven't used it myself to say so definitely.

If you want to run your own push server check out http://airnotifier.github.io/ for a solution but I think, when it all comes down to it, everything uses the Google Cloud Messaging service, all the push traffic routes through that to get to your Android device as far as I know.

Upvotes: 2

Related Questions