You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The socket channel-api works perfectly for one user at one point of time. But when i test it using a forloop, it would simply block the create request. So for the time being the only solution i could find is send one request and wait for 500 seconds. It's working now but i am worried about cases where many user will send create requests at the same point of time then it might miss few orders.
var i = 1;
function myLoop() {
setTimeout(function() {
var conn = new WebSocket('ws://54.238.247.144:5000/');
conn.onmessage = function(e) {
console.log(e.data);
};
var msg = {
stream: "ipad_orders",
payload: {
action: "create",
data: {
"unique_id": "123",
"push_token": "11",
"machine_id": 342,
"machine_name": "ok1",
"parlour": "parlour1",
"total_cost": 333,
"membership": false,
"delivered": false,
"items": "Hello" + i,
"qty": "1",
}
}
}
conn.onopen = () => conn.send(JSON.stringify(msg));
console.log("Sended" + i)
i++;
if (i < 10) {
myLoop();
}
}, 500)
}
myLoop();
The text was updated successfully, but these errors were encountered:
ashdaily
changed the title
when i try to send multiple create requests at the same time, it would simply miss some responses back.
when i try to send multiple create requests at the same time, it would simply miss some responses that i usually get back.
Jan 9, 2018
The socket channel-api works perfectly for one user at one point of time. But when i test it using a forloop, it would simply block the create request. So for the time being the only solution i could find is send one request and wait for 500 seconds. It's working now but i am worried about cases where many user will send create requests at the same point of time then it might miss few orders.
var i = 1;
function myLoop() {
setTimeout(function() {
var conn = new WebSocket('ws://54.238.247.144:5000/');
conn.onmessage = function(e) {
console.log(e.data);
};
var msg = {
stream: "ipad_orders",
payload: {
action: "create",
data: {
"unique_id": "123",
"push_token": "11",
"machine_id": 342,
"machine_name": "ok1",
"parlour": "parlour1",
"total_cost": 333,
"membership": false,
"delivered": false,
"items": "Hello" + i,
"qty": "1",
}
}
}
conn.onopen = () => conn.send(JSON.stringify(msg));
console.log("Sended" + i)
i++;
if (i < 10) {
myLoop();
}
}, 500)
}
myLoop();
The text was updated successfully, but these errors were encountered: