Package no.polaric.core.httpd
Class WebServer
java.lang.Object
no.polaric.core.httpd.WebServer
- All Implemented Interfaces:
ServerConfig.Web
Abstract base class for webserver setup.
A comcrete application should subclass this.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback for user logins.static class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWebServer(ServerConfig conf, int port, String psuri, String stpath, String stdir) Constructor for Webserver. -
Method Summary
Modifier and TypeMethodDescriptionio.javalin.Javalinapp()Return a Javalin objectReturn the auth servicevoidRegister a handler-function to be called when user-session is closed.voidRegister a handler-function to be called when user-session is opened.groupDb()Return the group-databasebooleanhasLoginUser(String user) Return true if the given userid is logged on to the system.Return a set of logged in users.intnClients()Number of clients.longnHttpReq()Number of http requests since startup.intNumber of logged-in clients.longnLogins()Number of logins since startup.voidnotifyLogin(String user) User login notification.voidnotifyLogout(String user) User logout notification.voidnotifyUser(String user, ServerConfig.Notification not) Send notification to a room.longnVisits()Number of visits since startup.voidRegister a handler-function to be called when user logs on to the system.voidRegister a handler-function to be called when user logs off the system.voidprotectDeviceUrl(String prefix) voidprotectUrl(String prefix) Protect a URL prefix (require login)voidprotectUrl(String prefix, String level) Protect a URL prefix.pubSub()return the pubsub servicevoidstart()Start the webserver and services.voidstop()Stop the webserver and servicesuserDb()Return the user-database
-
Field Details
-
_port
protected int _port -
_conf
-
-
Constructor Details
-
WebServer
Constructor for Webserver.- Parameters:
conf- ServerConfig objecctport- Server portpsuri- URL to servestpath- Path for serving static filesstdir- Directory where static files are to be found.
-
-
Method Details
-
start
public void start()Start the webserver and services.- Specified by:
startin interfaceServerConfig.Web
-
stop
Stop the webserver and services- Specified by:
stopin interfaceServerConfig.Web- Throws:
Exception
-
pubSub
return the pubsub service- Specified by:
pubSubin interfaceServerConfig.Web
-
nVisits
public long nVisits()Number of visits since startup.- Specified by:
nVisitsin interfaceServerConfig.Web
-
nLogins
public long nLogins()Number of logins since startup.- Specified by:
nLoginsin interfaceServerConfig.Web
-
nClients
public int nClients()Number of clients.- Specified by:
nClientsin interfaceServerConfig.Web
-
nLoggedin
public int nLoggedin()Number of logged-in clients.- Specified by:
nLoggedinin interfaceServerConfig.Web
-
nHttpReq
public long nHttpReq()Number of http requests since startup.- Specified by:
nHttpReqin interfaceServerConfig.Web
-
userDb
Return the user-database- Specified by:
userDbin interfaceServerConfig.Web
-
groupDb
Return the group-database -
authService
Return the auth service -
app
public io.javalin.Javalin app()Return a Javalin object -
loginUsers
Return a set of logged in users. The set is ordered. -
hasLoginUser
Return true if the given userid is logged on to the system. -
onLogin
Register a handler-function to be called when user logs on to the system. -
onLogout
Register a handler-function to be called when user logs off the system. -
createUserSes
Register a handler-function to be called when user-session is opened. Can be used to associate information to a user-session. -
closeUserSes
Register a handler-function to be called when user-session is closed. Can be used to clean up user-session information. -
notifyLogin
User login notification. To be called from AuthInfo class -
notifyLogout
User logout notification. To be called from AuthInfo class -
notifyUser
Send notification to a room.- Specified by:
notifyUserin interfaceServerConfig.Web
-
protectUrl
Protect a URL prefix (require login)- Specified by:
protectUrlin interfaceServerConfig.Web
-
protectUrl
Protect a URL prefix. Require login and authorization level ('operator' or 'admin')- Specified by:
protectUrlin interfaceServerConfig.Web
-
protectDeviceUrl
- Specified by:
protectDeviceUrlin interfaceServerConfig.Web
-