public abstract class AbstractConnection extends java.lang.Object implements Connection
Connection.SessionMode, Connection.UserSessionInitEvent
NAME
Constructor and Description |
---|
AbstractConnection() |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener listener)
Add a connection listener.
|
void |
addSubstitutionListener(UserSubstitutionListener listener)
Add a user substitution listener.
|
UserSession |
getSession()
Get current user session.
|
boolean |
isAlive()
Check if session is alive on middleware
|
boolean |
isAuthenticated()
Check if the client was authenticated.
|
boolean |
isConnected()
Check if the client is connected to the middleware.
|
void |
logout()
Log out of the system.
|
void |
removeConnectionListener(ConnectionListener listener)
Remove a connection listener.
|
void |
removeSubstitutionListener(UserSubstitutionListener listener)
Remove a user substitution listener.
|
void |
substituteUser(User substitutedUser)
Substitute a user in the current session with another user.
|
void |
update(UserSession session,
Connection.SessionMode sessionMode)
Update internal state with the passed user session object.
|
void |
update(UserSession session,
Connection.SessionMode sessionMode,
java.util.function.Consumer<Connection.UserSessionInitEvent> sessionInitializer)
Update internal state with the passed user session object.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkRememberMe, login, loginAnonymous, loginByRememberMe
public boolean isConnected()
Connection
isConnected
in interface Connection
public boolean isAuthenticated()
Connection
isAuthenticated
in interface Connection
@Nullable public UserSession getSession()
Connection
getSession
in interface Connection
public boolean isAlive()
Connection
isAlive
in interface Connection
public void update(UserSession session, Connection.SessionMode sessionMode) throws LoginException
Connection
update
in interface Connection
session
- new UserSession objectLoginException
- in case of unsuccessful updatepublic void update(UserSession session, Connection.SessionMode sessionMode, @Nullable java.util.function.Consumer<Connection.UserSessionInitEvent> sessionInitializer) throws LoginException
Connection
update
in interface Connection
session
- new UserSession objectsessionInitializer
- optional callback that will be triggered after session setup and before triggering
connection state change listenersLoginException
- in case of unsuccessful updatepublic void substituteUser(User substitutedUser)
Connection
New user is usually obtained from the current user's substitution list:
see User.getSubstitutions()
substituteUser
in interface Connection
substitutedUser
- new userpublic void logout()
Connection
logout
in interface Connection
public void addConnectionListener(ConnectionListener listener)
Connection
addConnectionListener
in interface Connection
listener
- listener to addpublic void removeConnectionListener(ConnectionListener listener)
Connection
removeConnectionListener
in interface Connection
listener
- listener to removepublic void addSubstitutionListener(UserSubstitutionListener listener)
Connection
addSubstitutionListener
in interface Connection
listener
- listener to addpublic void removeSubstitutionListener(UserSubstitutionListener listener)
Connection
removeSubstitutionListener
in interface Connection
listener
- listener to remove