Add "force" option to allowReconnect

This commit is contained in:
Winston Chang
2016-03-28 21:29:23 -05:00
parent 486d4d1c88
commit 7cb0882c73
3 changed files with 31 additions and 26 deletions

View File

@@ -82,12 +82,6 @@ var ShinyApp = function() {
var ws = new WebSocket(protocol + '//' + window.location.host + defaultPath);
ws.binaryType = 'arraybuffer';
// This flag indicates that reconnections are permitted by the server.
// When Shiny is running with Shiny Server, this flag will be present
// only on versions of SS that support reconnects. When running Shiny
// locally, this is set to true, because the "server" always permits
// reconnection.
ws.allowReconnect = true;
return ws;
};
@@ -225,8 +219,12 @@ var ShinyApp = function() {
}
// To try a reconnect, both the app (this.$allowReconnect) and the
// server (this.$socket.allowReconnect) must allow reconnections.
if (this.$allowReconnect === true && this.$socket.allowReconnect === true) {
// server (this.$socket.allowReconnect) must allow reconnections, or
// session$allowReconnect("force") was called. The "force" option should
// only be used for testing.
if ((this.$allowReconnect === true && this.$socket.allowReconnect === true) ||
this.$allowReconnect === "force")
{
var delay = reconnectDelay.next();
exports.showReconnectDialog(delay);
this.$scheduleReconnect(delay);
@@ -591,10 +589,11 @@ var ShinyApp = function() {
});
addMessageHandler('allowReconnect', function(message) {
if (!(message === true || message === false)) {
if (message === true || message === false || message === "force") {
this.$allowReconnect = message;
} else {
throw "Invalid value for allowReconnect: " + message;
}
this.$allowReconnect = message;
});
addMessageHandler('custom', function(message) {