H
H
hbrmdc2015-08-27 13:43:28
Node.js
hbrmdc, 2015-08-27 13:43:28

How does the frontend communicate with the database in a real-time webapp (on the example of a chat)?

When an eventListener is created within the frontend of the application, everything is logical and clear: there is a specific connection between the listener and its object, everything happens on the same client.
But how does eventListening work in dynamic real-time applications like chat?
As I understand it, the client must somehow register its acceptance on the server, and the server must send to the client every new line added to a specific database table.
Right?
is there a conceptual difference between solving this problem on laravel and nodejs backends?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Volintsev, 2015-08-27
@hbrmdc

Watch live chat on websocket technology chat.socket.io and the code of this chat on github https://github.com/socketio/socket.io/tree/master/...
The conceptual difference is that in this case the websocket server is already running on node.js and can access the database itself. And in the case of Laravel, you will need a layer between PHP and node.js, which is usually done on some asynchronous queue like RabbitMQ.

As of November 2013, Socket.io's list of supported browsers was:
Desktop:
mobile:
They achieve this level of support by using a variety of transports, depending on what the browser is capable of (again, from November 2013):
In Russian: they support all browser junk that is, through a combination of six technologies, ranging from modern WebSocket to JSONP

N
Night, 2015-08-27
@maxtm

long polling ajax
websockets

V
Viktor, 2015-08-27
@Levhav

For realtime applications, you need to be familiar with comet technology.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question