-
Notifications
You must be signed in to change notification settings - Fork 1
Sail Initialization Event Sequence
zuk edited this page Nov 29, 2012
·
4 revisions
The following is a typical event sequence during the bootstrapping, initialization, and authentication of a typical Sail app (we're currently trying to clean up this mess).
Note that all components can potentially listen to all events. For simplicity's sake, certain listeners are omitted in this diagram.
title Sail.App event sequence
participant sail.js
participant Sail.UI
participant Sail.App
participant Rollcall.Authenticator
participant Strophe.AutoConnector
participant Sail.Strophe
participant AuthStatusWidget
note over sail.js: Sail.init()
sail.js-->Sail.App: Sail.App.init()
sail.js-->Sail.UI: Sail.UI.init()
Sail.UI->Sail.App: ui.initialized!
sail.js->Sail.App: initialized!
Sail.App->Rollcall.Authenticator: .requestLogin()
note over Sail.App, Strophe.AutoConnector,Rollcall.Authenticator,AuthStatusWidget: user selects account to log in as
Rollcall.Authenticator->Strophe.AutoConnector: authenticated!
Rollcall.Authenticator->AuthStatusWidget: authenticated!
note over AuthStatusWidget:
show auth'ed user's username
end note
Strophe.AutoConnector->Sail.Strophe: .connect()
Sail.Strophe->Strophe.AutoConnector: .connectSuccess()
Strophe.AutoConnector->Sail.App: connected!
note over sail.js,Sail.UI,Sail.App,Rollcall.Authenticator,Strophe.AutoConnector,Sail.Strophe,AuthStatusWidget:
user is now online and using the app
end note
alt user clicks "Logout"
AuthStatusWidget->Rollcall.Authenticator: logout!
Rollcall.Authenticator->Rollcall.Authenticator: .unauthenticate()
Rollcall.Authenticator->Strophe.AutoConnector: unauthenticated!
Strophe.AutoConnector->Sail.Strophe: .disconnect()
note over Strophe.AutoConnector,Sail.Strophe:
(intentionally closes connection)
end note
else connection is lost (due to pinger timeout)
note over Sail.Strophe, Strophe.AutoConnector:
connection lost is detected because XMPP ping
(repeated every 14 seconds) times out
end note
Sail.Strophe->Strophe.AutoConnector: connection_lost!
Strophe.AutoConnector->Sail.Strophe: .connect()
note over Strophe.AutoConnector,Sail.Strophe:
(attempts to auto-reconnect)
end note
Sail.Strophe->Strophe.AutoConnector: .connectSuccess()
Strophe.AutoConnector->Sail.App: connected!
note over Sail.App:
yay we're back online!
end note
note over Sail.Strophe, Strophe.AutoConnector:
but if connect() failed, we're SOL
end note
end alt