O
O
OnYourLips2015-04-09 08:31:50
PHP
OnYourLips, 2015-04-09 08:31:50

Simple implementation of notifications from the server to the browser?

Let's say I'm doing a chat.
You need to notify clients when certain events occur.
The main site is written in PHP, and this is where the events appear.
The easiest way I see is:
1) On Node.js (socket.io), write a server (and put it behind nginx), which will be connected to the browser via WebSocket.
2) When an event occurs in the PHP part of the project, we send a message to rabbitmq.
3) If there is a message in rabbitmq, we send it to the Node.js daemon to the necessary clients in the browsers.
4) Monitor the Node.js server to the supervisor.
I don't like the technology zoo for this task.
How sooner can you?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexander Kubintsev, 2015-04-09
@OnYourLips

And what exactly in a set of technologies confuses? Well, as an option, you can replace node.js with Ratchet, -1 YP will be in the list.
So in fact, do not subtract, do not add.

R
Roman Scriabin, 2015-04-09
@Romanche

easier - longpoling.
on the client using ajax send a request to the server. Set a timeout of 1 minute. On the server, you make a loop that returns a value if there are changes + sleep(1) in the iteration. Well, set the time - as convenient. in case of changes - send data - ajax accepts and notifies.

M
Maxim, 2015-04-09
Antonikhin @STJ

The simplest is a socket. It will be nowhere easier.

N
Nodlik, 2015-04-09
@Nodlik

For me, the easiest way was to use server sent events
For web sockets, in principle, node js is not necessary, the php script can also be made to be a demon.
And communication between the daemon and the site is easier, yes, through rabbitmq.

T
theaidem, 2015-04-09
@theaidem

As I understand it, you don’t want to put the node in the zoo, then take Go, it’s simple, beautiful, a minimum of dependencies, it will be easier to scale

V
Viktor, 2015-06-27
@Levhav

You can try Star.Comet, it's just because you will only have php and js on your side, and everything else is already ready and works in saas mode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question