@Component(value="cuba_Connection") @Scope(value="vaadin") public class ConnectionImpl extends EventRouter implements Connection
Connection
implementation for web-client.Connection.StateChangeEvent, Connection.StateChangeListener, Connection.UserSubstitutedEvent, Connection.UserSubstitutionListener
NAME
Constructor and Description |
---|
ConnectionImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addStateChangeListener(Connection.StateChangeListener listener)
Add a connection listener.
|
void |
addUserSubstitutionListener(Connection.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 |
login(Credentials credentials)
Authenticates a user, starts session and changes state of the connection.
|
void |
logout()
Log out of the system.
|
void |
removeStateChangeListener(Connection.StateChangeListener listener)
Remove a connection listener.
|
void |
removeUserSubstitutionListener(Connection.UserSubstitutionListener listener)
Remove a user substitution listener.
|
void |
substituteUser(User substitutedUser)
Substitute a user in the current session with another user.
|
addListener, addListener, fireEvent, hasListeners, removeListener, removeListener, removeListeners
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSessionNN, login, loginAnonymous, loginByRememberMe
loginAfterExternalAuthentication, logoutExternalAuthentication
public void login(Credentials credentials) throws LoginException
Connection
login
in interface Connection
credentials
- credentialsLoginException
- if authentication failspublic void logout()
Connection
logout
in interface Connection
@Nullable public UserSession getSession()
Connection
getSession
in interface Connection
public 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 boolean isConnected()
Connection
isConnected
in interface Connection
public boolean isAuthenticated()
Connection
isAuthenticated
in interface Connection
public boolean isAlive()
Connection
isAlive
in interface Connection
public void addStateChangeListener(Connection.StateChangeListener listener)
Connection
addStateChangeListener
in interface Connection
listener
- listener to addpublic void removeStateChangeListener(Connection.StateChangeListener listener)
Connection
removeStateChangeListener
in interface Connection
listener
- listener to removepublic void addUserSubstitutionListener(Connection.UserSubstitutionListener listener)
Connection
addUserSubstitutionListener
in interface Connection
listener
- listener to addpublic void removeUserSubstitutionListener(Connection.UserSubstitutionListener listener)
Connection
removeUserSubstitutionListener
in interface Connection
listener
- listener to remove