Skip to content

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.

UML Diagram

http://www.websequencediagrams.com/?lz=dGl0bGUgU2FpbC5BcHAgZXZlbnQgc2VxdWVuY2UKCnBhcnRpY2lwYW50IHNhaWwuanMABw0ANAVVSQACEkFwcAAwDVJvbGxjYWxsLkF1dGhlbnRpY2F0b3IAPg50cm9waGUuQXV0b0Nvbm5lYwAREWFpbC4AIAcAgQ4NQXV0aFN0YXR1c1dpZGdldAoKbm90ZSBvdmVyAIEvCDoAgV8GaW5pdCgpCgCBRQctLT4AgXMIABkHQXBwAA0XVUkAPAdVSQA-CACBdwcAOQx1aQBeBWlhbGl6ZWQhAGAJAF0LABMNAIJyCC0-AIIMFjogLnJlcXVlc3RMb2dpbigpAIFPDAAbGHVzZXIgc2VsZWN0cyBhY2NvdW50IHRvIGxvZyBpbiBhcwoAgnkWLT4AgjkQOiBhAIMmCmVkIQAgGQCDKBUALREAgwwKAFgRCnNob3cAaQUnZWQAgT0FJ3MAgUQFbmFtZQppbiB0b3AgcmlnaHQgY29ybmVyCmVuZCBub3RlCgCEJBUAg1MHAIROBzogLmMAhE0GAIMvCACEZwcAgSEZACgIU3VjY2VzcygpAEodAIQ8BQBbB2VkIQCEbRMsAIYkBwACBkFwcCwAhX0WLACFchUAOAYAhhsHLACCKxIAg20FaXMgbm93IG9ubGluZSBhbmQgdXNpbmcgdGhlIGFwcACCJwoKYWx0AIQfBmNsaWNrcyAiTG9nb3V0IgoKAIY6EACEfhpsAC4FAIN4GgCFNxl1bgCESAwoKQCEYisALQ4AhDIfY2xlYXIAhDoYIACENR4AhTgvAIEHEQCEbSZkaXMAhQwKAIkoCgCDYCI6IAooaW50ZW50aW9uYWxseSBjbG9zZXMAhHsIaW9uKQCDZAtlbHNlABALIGlzIGxvc3QgKGR1ZSB0byBwaW5nZXIgdGltZW91dACIVg0AhGsNAIsNFjoKAFAMAFQFaXMgZGV0AIYHBSBiZWNhdXNlIFhNUFAAZQUKIChyZXBlYXRlZCBldmVyeSAxNCBzZWNvbmRzKQCBAAVzIG91dACHVQsAhwwkAIFwCl9sb3N0AIJbKACCRjphdHRlbXB0cyB0byBhdXRvLXJlAIhcBwCCcAsAiAhjAIMdD0FwcDoKeWF5IHdlJ3JlIGJhY2sAiAsHIQCKKAoAgzEvYnV0IGlmAIlYCCgpIGZhaWxlZCwAXQdTT0wAiwMKZW5kIGFsdAoKCg&s=roundgreen

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
Clone this wiki locally