-
Notifications
You must be signed in to change notification settings - Fork 347
Open
Description
Server version: 2.0.0-beta-7
Client version: 2.0.0-beta-7
Not sure if I am doing this the right way but I can't seem to reconnect to the server after a temporary disconnect. Even though the client can't reconnect on it own, it should be possible to reconnect manually without refreshing the browser. Am I missing something or does it not work?
I run the code below and then close the server and start it again.
Example client code:
let message = {
text: "What a beautiful horizon!",
datetime: new Date(),
author: "@dalanmiller"
}
let horizon = Horizon();
let chat = horizon("messages");
let isConnected = false;
let handle;
document.addEventListener("DOMContentLoaded", function(event) {
document.querySelector('button').addEventListener('click', e => {
console.log('CLICK');
chat.store(message);
});
chat.watch().subscribe(docs => console.log('DOCUMENTS', docs.length));
horizon.status(s => {
console.log('status', s);
});
horizon.onReady(s => {
if (handle) {
clearInterval(handle);
}
});
horizon.onSocketError(e => {
console.log('socket error', e);
//horizon.disconnect();
//horizon = null;
handle = setInterval(() => {
console.log('RECONNECTING');
//horizon = Horizon();
//horizon.connect();
chat.watch().subscribe((docs) => {console.log(docs.map(e => e.text))});
}, 10000);
});
});