A
A
Alexey So2016-04-01 00:52:07
Android
Alexey So, 2016-04-01 00:52:07

Which way to choose for the organization of network data exchange?

The situation is as follows - there is an application and a website.
On the site, the user presses a button - the android device must find out about this guaranteed and quickly.
Now the previous developers simply contact the server every 30 seconds to find out if the (conditional button) is pressed.
All this wildly eats resources.
Any idea how to notify android device?
I understand that there are push notifications, but they do not guarantee delivery + in theory, push notifications can be disabled.
I thought combined methods - push + increase the frequency of calls.
Tell me pliz, there are some more interesting options?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2016-04-01
@leahch

Comet, have you tried it? It works for me, I have to reconnect, though I still have to, but the timeout can be done for 3 minutes, it plays a role only when the connection of one of the parties is disconnected, when the second party does not recognize it. All data comes instantly! You can hold a million connections at the same time.
We search for the implementation of comet for your framework in Google by the word comet + <framework>
I have something like this:

from twisted.internet import reactor

class MyRequestHandler(web.RequestHandler):
    @web.asynchronous
    def get(self):
        self.write("Processing your request...")
        reactor.callLater(5, self.do_something)

    def do_something(self):
        self.finish("done!")

V
VZVZ, 2016-04-01
@VZVZ

Why not abandon HTTP altogether in favor of bare TCP (or WebSockets - then NodeJS is ideal for a server)?
The client is connected to the server - and connection simply remains open. The server sends a packet after xxx time - the client immediately receives it, while the connection is still open. Also vice versa (client - server).
I doubt that you can come up with something better in terms of performance for network exchange than bare TCP.
If someone knows a better option - I will listen carefully and I will be grateful.

A
Alexey So, 2016-04-01
@mayhembr

From the point of view of the battery - TCP or Comet will be gluttonous?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question