Class WsNotifier

java.lang.Object
no.polaric.core.httpd.ServerBase
no.polaric.core.httpd.WsNotifier
All Implemented Interfaces:
SesNotifier
Direct Known Subclasses:
NodeWs, PubSub

public abstract class WsNotifier extends ServerBase implements SesNotifier
  • Field Details

  • Constructor Details

  • Method Details

    • newClient

      public abstract WsNotifier.Client newClient(io.javalin.websocket.WsContext ctx)
      Factory method
    • nClients

      public int nClients()
      Return number of clients.
    • nVisits

      public long nVisits()
      Return number of visits
    • nLogins

      public long nLogins()
      Return number of logins
    • nLoggedIn

      public int nLoggedIn()
      Return number of logged-in users
    • clients

      public Collection<WsNotifier.Client> clients()
      Return collection of clients
    • authenticate

      public AuthInfo authenticate(String qstring)
      Do authentication based on URL query-string. Return an AuthInfo object if success. Return null if failure. The query string have 3 or 4 parameters: (1) userid, (2) nonce, (3) hmac, (4) role (optional). When computing the hmac the data field is empty.
    • closeSes

      protected void closeSes(io.javalin.websocket.WsContext ctx)
      Close the client session.
    • onOpenSes

      public void onOpenSes(SesNotifier.SHandler h)
      Register a callback for open-session events
      Specified by:
      onOpenSes in interface SesNotifier
    • onCloseSes

      public void onCloseSes(SesNotifier.SHandler h)
      Register a callback for close-session events
      Specified by:
      onCloseSes in interface SesNotifier
    • subscribe

      protected boolean subscribe(io.javalin.websocket.WsContext ctx, WsNotifier.Client client)
      Subscribe a client to the service. Should be overridden in subclass. This may include authorization, preferences, etc..
      Returns:
      true if subscription is accepted. False if rejected.
    • postText

      public void postText(Function<WsNotifier.Client,String> txt, Predicate<WsNotifier.Client> pred)
      Distribute a text to the clients for which the predicate evaluates to true.
    • postText

      public void postText(String txt, Predicate<WsNotifier.Client> pred)
    • sesId

      public static String sesId(io.javalin.websocket.WsContext ctx)
    • start

      public void start(String uri)