Package no.polaric.core.httpd
Class WsNotifier
java.lang.Object
no.polaric.core.httpd.ServerBase
no.polaric.core.httpd.WsNotifier
- All Implemented Interfaces:
SesNotifier
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface no.polaric.core.httpd.SesNotifier
SesNotifier.SHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<io.javalin.websocket.WsContext,
WsNotifier.Client> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(String qstring) Do authentication based on URL query-string.clients()
Return collection of clientsprotected void
closeSes
(io.javalin.websocket.WsContext ctx) Close the client session.int
nClients()
Return number of clients.abstract WsNotifier.Client
newClient
(io.javalin.websocket.WsContext ctx) Factory methodint
Return number of logged-in userslong
nLogins()
Return number of loginslong
nVisits()
Return number of visitsvoid
Register a callback for close-session eventsvoid
Register a callback for open-session eventsvoid
postText
(String txt, Predicate<WsNotifier.Client> pred) void
postText
(Function<WsNotifier.Client, String> txt, Predicate<WsNotifier.Client> pred) Distribute a text to the clients for which the predicate evaluates to true.static String
sesId
(io.javalin.websocket.WsContext ctx) void
protected boolean
subscribe
(io.javalin.websocket.WsContext ctx, WsNotifier.Client client) Subscribe a client to the service.Methods inherited from class no.polaric.core.httpd.ServerBase
addSubtype, cleanPath, clientIpAddr, conf, deserializeJson, fixText, fromJson, getAuthInfo, icon, metaTag, protect, protect, roundDeg, serializeJson, systemNotification, toJson, wServer
-
Field Details
-
_clients
-
-
Constructor Details
-
WsNotifier
-
-
Method Details
-
newClient
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
Return collection of clients -
authenticate
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
Register a callback for open-session events- Specified by:
onOpenSes
in interfaceSesNotifier
-
onCloseSes
Register a callback for close-session events- Specified by:
onCloseSes
in interfaceSesNotifier
-
subscribe
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
Distribute a text to the clients for which the predicate evaluates to true. -
postText
-
sesId
-
start
-