Refactor Session and ApiContext to allow cancelation

This commit is contained in:
Lucien Greathouse
2019-01-11 15:45:32 -08:00
parent f21f01be1a
commit 30ce927621
3 changed files with 83 additions and 75 deletions

View File

@@ -95,8 +95,9 @@ function App:render()
local success, session = Session.new({
address = address,
port = port,
onError = function()
Logging.trace("Session terminated")
onError = function(message)
Logging.warn("%s", tostring(message))
Logging.trace("Session terminated due to error")
self.currentSession = nil
self:setState({
@@ -145,12 +146,13 @@ function App:didMount()
if self.state.sessionStatus == SessionStatus.Connected then
Logging.trace("Disconnecting session")
self.currentSession:disconnect()
self.currentSession = nil
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
error("TODO: Actually disconnect old session")
Logging.trace("Session terminated by user")
elseif self.state.sessionStatus == SessionStatus.Disconnected then
Logging.trace("Starting session configuration")