Added a way to set a custom callback function to be called
when the client detects that it has been disconnected
from the server.
Prior to this patch, the behavior was always to print to
the jlog (browser page): "The connexion to the server seems
to have been lost." Now the programmer can customize this
behavior.
Here is a fully-functional and tested usage case:
import stdlib.core.rpc.core;
import stdlib.web.client;
client function my_connection_lost_handler() {
Client.alert("connection lost, press OK to reload");
Client.reload();
}
function setup_handler() {
Session.set_connection_lost_handler(my_connection_lost_handler);
}
function page() {
<div onready={function(_) { setup_handler() }}>
this is the <strong>custom connection handler
test</strong> page. try killing the server and
waiting a couple of minutes.
</div>
}
Server.start(Server.http,
{title:"connection handler test", page:page})
Caveats: like many functions in Opa, if you call
set_connection_lost_handler before the client has finished
loading the page, your app will hang. To avoid this, always
call it from within an `onready` or another type of event
handler.