public Sub StartServerHTTP2(srvr As Server, srvrName As String, srvrPort As Int, SSLsvrPort As Int, SSLKeyStoreFileName As String, SSLKeyStorePassword As String, SSLKeyManagerPassword As String)
ABM.WriteAppLauchPageToDisk(AppPage, File.DirApp & "/www/" & ABMShared.AppName, "index.html", ABMShared.NeedsAuthorization)
Dim ssl As SslConfiguration
ssl.Initialize
ssl.SetKeyStorePath(File.DirApp, SSLKeyStoreFileName) 'path to keystore file
ssl.KeyStorePassword = SSLKeyStorePassword
ssl.KeyManagerPassword = SSLKeyManagerPassword
ssl.EnableConscryptProvider
srvr.SetSslConfiguration(ssl, SSLsvrPort)
' start the server
srvr.Initialize(srvrName)
' uncomment this if you want to directly access the app in the url without having to add the app name
' e.g. 192.168.1.105:51042 or 192.168.1.105 if you are using port 80
srvr.AddFilter( "/", "ABMRootFilter", False )
' NEW V3 Cache Control
srvr.AddFilter("/*", "ABMCacheControl", False)
' NEW 4.00 custom error pages (optional) Needs the ABMErrorHandler class
srvr.SetCustomErrorPages(CreateMap("org.eclipse.jetty.server.error_page.global": "/" & ABMShared.AppName & "/error")) ' OPTIONAL
srvr.AddHandler("/" & ABMShared.AppName & "/error", "ABMErrorHandler", False) ' OPTIONAL
srvr.AddWebSocket("/ws/" & ABMShared.AppName, "ABMApplication")
For i =0 To Pages.Size - 1
srvr.AddWebSocket("/ws/" & ABMShared.AppName & "/" & Pages.Get(i) , Pages.Get(i))
If PageNeedsUpload.Get(i) Then
srvr.AddHandler("/" & ABMShared.AppName & "/" & Pages.Get(i) & "/abmuploadhandler", "ABMUploadHandler", False)
End If
Next
srvr.AddBackgroundWorker("ABMCacheScavenger")
srvr.Port = srvrPort
srvr.Http2Enabled = True
#If RELEASE
srvr.SetStaticFilesOptions(CreateMap("gzip":True,"dirAllowed":False))
#Else
srvr.SetStaticFilesOptions(CreateMap("gzip":False,"dirAllowed":False))
#End If
srvr.Start
Dim joServer As JavaObject = srvr
joServer.GetFieldJO("server").RunMethod("stop", Null)
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionCookieConfig", Null).RunMethod("setMaxAge", Array(31536000)) ' 1 year
' NEW FEATURE! Each App has its own Session Cookie
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionCookieConfig", Null).RunMethod("setName", Array(ABMShared.AppName.ToUpperCase))
joServer.GetFieldJO("server").RunMethod("start", Null)
Dim secs As Long = ABMShared.CacheScavengePeriodSeconds ' must be defined as a long, else you get a 'java.lang.RuntimeException: Method: setIntervalSec not matched.' error
joServer.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionIdManager", Null).RunMethodJO("getSessionHouseKeeper", Null).RunMethod("setIntervalSec", Array As Object(secs))
Dim jo As JavaObject = srvr
Dim connectors() As Object = jo.GetFieldJO("server").RunMethod("getConnectors", Null)
Dim timeout As Long = ABMShared.SessionMaxInactiveIntervalSeconds*1000
For Each c As JavaObject In connectors
c.RunMethod("setIdleTimeout", Array(timeout))
Next
ABMShared.CachedPages = srvr.CreateThreadSafeMap
End Sub