Class WebServer

java.lang.Object
no.polaric.core.httpd.WebServer
All Implemented Interfaces:
ServerConfig.Web

public abstract class WebServer extends Object implements ServerConfig.Web
  • Field Details

    • _port

      protected int _port
    • _conf

      protected ServerConfig _conf
  • Constructor Details

    • WebServer

      public WebServer(ServerConfig conf, int port, String psuri, String stpath, String stdir)
      Constructor for Webserver.
      Parameters:
      conf - ServerConfig objecct
      port - Server port
      psuri - URL to serve
      stpath - Path for serving static files
      stdir - Directory where static files are to be found.
  • Method Details

    • start

      public void start()
      Start the webserver and services.
      Specified by:
      start in interface ServerConfig.Web
    • stop

      public void stop() throws Exception
      Stop the webserver and services
      Specified by:
      stop in interface ServerConfig.Web
      Throws:
      Exception
    • pubSub

      public PubSub pubSub()
      return the pubsub service
      Specified by:
      pubSub in interface ServerConfig.Web
    • nVisits

      public long nVisits()
      Number of visits since startup.
      Specified by:
      nVisits in interface ServerConfig.Web
    • nLogins

      public long nLogins()
      Number of logins since startup.
      Specified by:
      nLogins in interface ServerConfig.Web
    • nClients

      public int nClients()
      Number of clients.
      Specified by:
      nClients in interface ServerConfig.Web
    • nLoggedin

      public int nLoggedin()
      Number of logged-in clients.
      Specified by:
      nLoggedin in interface ServerConfig.Web
    • nHttpReq

      public long nHttpReq()
      Number of http requests since startup.
      Specified by:
      nHttpReq in interface ServerConfig.Web
    • userDb

      public UserDb userDb()
      Return the user-database
      Specified by:
      userDb in interface ServerConfig.Web
    • groupDb

      public GroupDb groupDb()
      Return the group-database
    • authService

      public AuthService authService()
      Return the auth service
    • app

      public io.javalin.Javalin app()
      Return a Javalin object
    • loginUsers

      public SortedSet<String> loginUsers()
      Return a set of logged in users. The set is ordered.
    • hasLoginUser

      public boolean hasLoginUser(String user)
      Return true if the given userid is logged on to the system.
    • onLogin

      public void onLogin(WebServer.UserLogin not)
      Register a handler-function to be called when user logs on to the system.
    • onLogout

      public void onLogout(WebServer.UserLogin not)
      Register a handler-function to be called when user logs off the system.
    • createUserSes

      public void createUserSes(AuthInfo.SesCreateFunc f)
      Register a handler-function to be called when user-session is opened. Can be used to associate information to a user-session.
    • closeUserSes

      public void closeUserSes(AuthInfo.SesCloseFunc f)
      Register a handler-function to be called when user-session is closed. Can be used to clean up user-session information.
    • notifyLogin

      public void notifyLogin(String user)
      User login notification. To be called from AuthInfo class
    • notifyLogout

      public void notifyLogout(String user)
      User logout notification. To be called from AuthInfo class
    • notifyUser

      public void notifyUser(String user, ServerConfig.Notification not)
      Send notification to a room.
      Specified by:
      notifyUser in interface ServerConfig.Web
    • protectUrl

      public void protectUrl(String prefix)
      Protect a URL prefix (require login)
      Specified by:
      protectUrl in interface ServerConfig.Web
    • protectUrl

      public void protectUrl(String prefix, String level)
      Protect a URL prefix. Require login and authorization level ('operator' or 'admin')
      Specified by:
      protectUrl in interface ServerConfig.Web
    • protectDeviceUrl

      public void protectDeviceUrl(String prefix)
      Specified by:
      protectDeviceUrl in interface ServerConfig.Web