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
I used your demo messenger app and am having an issue where if the server goes down, the watcher on the client (chat.html) no longer works. I added the following to the server:
// Send a new message to the client every 5 seconds
var i=0;
setInterval(function() {
if(syc.list('messages')) {
var message = {
screenname: 'FROM_SERVER',
content: 'Test #' + i++
};
console.log('Sending message: ' + JSON.stringify(message));
syc.list('messages').push(message);
}
},5000);
When I refresh the client it recovers and displays the new messages no problem, but when I stop and start the server, the client receives the message but the watch no longer works.
I also tried adding a new watch whenever the socket connects on the client by doing the following:
socket.on('connect', function() {
console.log('SOCKET.ON.connect');
Syc.loaded(function () {
Syc.list('messages').forEach(function (message) {
addMessage(message);
});
// Whenever a new message is added to the array,
Syc.watch(Syc.list('messages'), function (change) {
addMessage(change.newValue);
});
});
});
But that didn't fix the issue, the client keeps receiving the changes from the server but the watched 'messages' callback does not get triggered.
Great library, thanks for creating it... it's going to simplify my client/server code drastically, I just need it to be reliable even when the server is brought down.
Charlie
The text was updated successfully, but these errors were encountered:
I did a slight modification to the chat.html code, by adding a 0ms timeout before we call Syc.watch and it fixed the problem. Now the it is watching the new id, and not the old one.
I used your demo messenger app and am having an issue where if the server goes down, the watcher on the client (chat.html) no longer works. I added the following to the server:
// Send a new message to the client every 5 seconds
var i=0;
setInterval(function() {
if(syc.list('messages')) {
var message = {
screenname: 'FROM_SERVER',
content: 'Test #' + i++
};
console.log('Sending message: ' + JSON.stringify(message));
syc.list('messages').push(message);
}
},5000);
When I refresh the client it recovers and displays the new messages no problem, but when I stop and start the server, the client receives the message but the watch no longer works.
I also tried adding a new watch whenever the socket connects on the client by doing the following:
socket.on('connect', function() {
console.log('SOCKET.ON.connect');
Syc.loaded(function () {
Syc.list('messages').forEach(function (message) {
addMessage(message);
});
// Whenever a new message is added to the array,
Syc.watch(Syc.list('messages'), function (change) {
addMessage(change.newValue);
});
});
});
But that didn't fix the issue, the client keeps receiving the changes from the server but the watched 'messages' callback does not get triggered.
Great library, thanks for creating it... it's going to simplify my client/server code drastically, I just need it to be reliable even when the server is brought down.
Charlie
The text was updated successfully, but these errors were encountered: