Package no.polaric.core.httpd
Class WebServer
java.lang.Object
no.polaric.core.httpd.WebServer
- All Implemented Interfaces:
ServerConfig.Web
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback 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.Javalin
app()
Return a Javalin objectReturn the auth servicevoid
Register a handler-function to be called when user-session is closed.void
Register a handler-function to be called when user-session is opened.groupDb()
Return the group-databaseboolean
hasLoginUser
(String user) Return true if the given userid is logged on to the system.Return a set of logged in users.int
nClients()
Number of clients.long
nHttpReq()
Number of http requests since startup.int
Number of logged-in clients.long
nLogins()
Number of logins since startup.void
notifyLogin
(String user) User login notification.void
notifyLogout
(String user) User logout notification.void
notifyUser
(String user, ServerConfig.Notification not) Send notification to a room.long
nVisits()
Number of visits since startup.void
Register a handler-function to be called when user logs on to the system.void
Register a handler-function to be called when user logs off the system.void
protectDeviceUrl
(String prefix) void
protectUrl
(String prefix) Protect a URL prefix (require login)void
protectUrl
(String prefix, String level) Protect a URL prefix.pubSub()
return the pubsub servicevoid
start()
Start the webserver and services.void
stop()
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:
start
in interfaceServerConfig.Web
-
stop
Stop the webserver and services- Specified by:
stop
in interfaceServerConfig.Web
- Throws:
Exception
-
pubSub
return the pubsub service- Specified by:
pubSub
in interfaceServerConfig.Web
-
nVisits
public long nVisits()Number of visits since startup.- Specified by:
nVisits
in interfaceServerConfig.Web
-
nLogins
public long nLogins()Number of logins since startup.- Specified by:
nLogins
in interfaceServerConfig.Web
-
nClients
public int nClients()Number of clients.- Specified by:
nClients
in interfaceServerConfig.Web
-
nLoggedin
public int nLoggedin()Number of logged-in clients.- Specified by:
nLoggedin
in interfaceServerConfig.Web
-
nHttpReq
public long nHttpReq()Number of http requests since startup.- Specified by:
nHttpReq
in interfaceServerConfig.Web
-
userDb
Return the user-database- Specified by:
userDb
in 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:
notifyUser
in interfaceServerConfig.Web
-
protectUrl
Protect a URL prefix (require login)- Specified by:
protectUrl
in interfaceServerConfig.Web
-
protectUrl
Protect a URL prefix. Require login and authorization level ('operator' or 'admin')- Specified by:
protectUrl
in interfaceServerConfig.Web
-
protectDeviceUrl
- Specified by:
protectDeviceUrl
in interfaceServerConfig.Web
-