Answer the question
In order to leave comments, you need to log in
In what form is it better to transfer data from a websocket server?
I have one project at once for the server and for the client. The server part is in a separate server folder.
I need to send data and receive on the client
. The client will be a Vue JS application.
The server will have many methods that will send data in different categories. For example, one method sends numbers by temperature, another - by air humidity, the third - by pressure
An example of one of the methods:
function getRandomValue(){
return Math.floor(Math.random() * (50 - 5 + 1)) + 5;
}
io.on("connection", socket => {
setInterval(() => {
socket.broadcast.emit("newData", getRandomValue())
}, 1000)
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question