Clean up correctly after API caller leaves

This commit is contained in:
Joe Cheng
2017-01-06 18:00:03 -08:00
parent c1d92c2767
commit 417f7f7236

View File

@@ -83,6 +83,14 @@ apiHandler <- function(serverFuncSource) {
)
shinysession <- ShinySession$new(ws)
on.exit({
try({
# Clean up the session. Very important, so that observers
# and such don't hang around, and to let memory get gc'd.
shinysession$wsClosed()
appsByToken$remove(shinysession$token)
})
}, add = TRUE)
appsByToken$set(shinysession$token, shinysession)
shinysession$setShowcase(.globals$showcaseDefault)
@@ -173,7 +181,13 @@ apiWsHandler <- function(serverFuncSource) {
ws$close()
})
# TODO: Handle ws$onClose()
ws$onClose(function() {
# Clean up the session. Very important, so that observers
# and such don't hang around, and to let memory get gc'd.
shinysession$wsClosed()
appsByToken$remove(shinysession$token)
})
# TODO: What to do on ws$onMessage?
}
}