M
M
mozart13372016-05-16 01:06:55
Node.js
mozart1337, 2016-05-16 01:06:55

How to organize an array of socket.io node js events?

Hello. There was such a problem. Let's say we have "very important data" that the client should receive as soon as possible. For example, if the client has a bad Internet connection and it can start missing events sent over the web socket, how to fix this situation. Or, for example, when the site is loaded, the data is loaded by the usual get request (primary) and then socket.io is immediately connected to load new information in real time. But there is a question, what if an event occurs between receiving data on the initial page load and connecting the client to socket.io, it turns out that it will not be received by the client already? How to avoid it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2016-05-16
@SagePtr

For example, send the id of the last received event to the server and, after connecting via socket.io, send events with a large id.

C
catHD, 2016-05-16
@catHD

2 ways:
1. Reinvent the wheel: write a layer that uses sequence and confirmation of data receipt.
2. We use ready-made frameworks: sails

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question