Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Log(" ----"&Name&" view ws Connected")
ws = WebSocket1
ABMPageId = ABM.GetPageID( page, Name, ws)
Dim session As HttpSession = ABM.GetSession(ws, ABMShared.SessionMaxInactiveIntervalSeconds)
If session.IsNew Then
session.Invalidate
ABMShared.NavigateToPage(ws, "", "./")
Return
End If
ABMShared.NeedsAuthorization = True
If ABMShared.NeedsAuthorization Then
If session.GetAttribute2("IsAuthorized", "") = "" Then
ABMShared.NavigateToPage(ws, ABMPageId, "../")
Return
End If
End If
ABM.UpdateFromCache(Me, ABMShared.CachedPages, ABMPageId, ws)
If page.ComesFromPageCache Then
' refresh the page
page.Refresh
' because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL
page.FinishedLoading
Else
If page.WebsocketReconnected Then
Log("Websocket reconnected")
' when we have a client that doesn't have the page in cache and it's websocket reconnected and also it's session is new - basically when the client
' had internet problems and it's session (and also cache) expired before he reconnected so the user has content in the browser but we don't have
' any on the server. So we need to reload the page.
' when a client that doesn't have the page in cache and it's websocket reconnected but it's session is not new - when the client had internet
' problems and when he reconnected it's session was valid but he had no cache for this page we need to reload the page as the user browser has
' content, reconnected but we have no content in cache
ABMShared.NavigateToPage (ws, ABMPageId, "./" & page.PageHTMLName)
Else
' when the client did not reconnected it doesn't matter if the session was new or not because this is the websockets first connection so no dynamic
' content in the browser ... we are going to serve the dynamic content...
Log("Websocket first connection")
page.Prepare
ConnectPage
End If
End If
page.RestoreNavigationBarPosition
page.NavigationBar.Refresh
Log(Name &ABMPageId)
End Sub