A
A
Andrew2017-01-18 12:13:23
PHP
Andrew, 2017-01-18 12:13:23

How to send a request from the server (PHP) to the application?

Hello dear friends.
Could you suggest the best way to send requests from the server to the application? (Reverse interaction, so to speak)
Let's say notification of new messages (not Push).
Making a socket connection?
Constant monitoring of events from the application itself?
long polling?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Andrey Myvrenik, 2017-01-18
@gim0

I would suggest WebSockets, but since the question is specifically about PHP, the other option is long polling .

D
davidnum95, 2017-01-18
@davidnum95

Isn't it easier to make a service on node.js (socket.io)? The PHP application will simply send a notification to the node, and it will decide how to send the notification to the client. Accordingly, on the client, it will be necessary to implement a connection to the node and processing notifications.

A
Alexander Momot, 2017-01-18
@AlexMt

Can be more? The application is in the local network, is the ip address of the device visible? You can send an HTTP request to a specific ip/host. The phone on which the application will have ip. The application must be a listener, that is, a server. Work and listen on a specific port. Or do you plan that the application will be distributed, located in different networks?
For maintaining a persistent connection (bidirectional channel) - sockets are best. In addition, there are even HTTP sockets . But the phone / tablet (application) should be the INITIATOR of creating a bidirectional connection.

A
Alexander Bublikov, 2017-01-18
@bublik462

Socket.io is suitable for this task, but it seems to be for node.js, but it can be easily integrated into PHP.

M
mitaichik, 2017-01-18
@mitaichik

If you do not need direct super realtime, use https://firebase.google.com/docs/cloud-messaging/ and you will be happy. The people write that they reach in 3-4 seconds, I myself will try to use it in the near future.
If you need real-there - then use sockets. True, PHP is not the best choice for working with sockets, although it is possible on it, but its single-threading creates problems, and you can’t do without crutches (or maybe there is some kind of lib/extension already - xs). If you code on Android, that is, you know Java - use it, there the socket server is created out of the box with ten lines of code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question