Class PerspectiveSessionCollection
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.perspective.gateway.session.PerspectiveSessionCollection
-
- All Implemented Interfaces:
java.util.EventListener
,javax.servlet.http.HttpSessionBindingListener
public class PerspectiveSessionCollection extends AbstractLifecycle implements javax.servlet.http.HttpSessionBindingListener
This is the top level of session object for a collection of "project" sessions. A given "auth session" (which correlates to a browser instance) can run multiple projects simultaneously because of tabbed browsing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PerspectiveSessionCollection.Builder
-
Field Summary
Fields Modifier and Type Field Description PerspectiveContext
context
java.lang.String
id
id of the parent HttpSession that owns usSessionScope
scope
"scope" of this session - Client or Designerstatic java.lang.String
SESSION_KEY
This is the name ( "perspective-session" ) used to store this object on an HttpSessionjava.lang.String
uuid
UUID to help keep track of sessions by session monitor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PerspectiveSessionCollection.Builder
builder()
java.util.Optional<InternalSession>
findProjectSession(java.lang.String project)
PerspectiveContext
getContext()
NativeDevice
getDevice()
com.inductiveautomation.ignition.common.gson.Gson
getGson()
java.util.Locale
getLocale()
Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header.java.util.List<java.util.Locale>
getLocales()
Returns aList
ofLocale
objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header in the request which created this session.InternalSession
getOrCreateSession(java.lang.String projectName)
Fetch theInternalSession
associated with the given project name and version or create one if it does not exist in this session collection.InternalSession
getOrCreateSession(java.lang.String projectName, java.util.UUID sessionId)
java.lang.Long
getRecentBytesSent()
SessionScope
getScope()
com.google.common.collect.ImmutableCollection<java.lang.String>
getSecurityZones()
java.math.BigInteger
getTotalBytesSent()
void
handleLogs(LogMessage log)
Called when the client has POSTed log messages back to the server.boolean
isBrokeredAuth()
boolean
isValidMobile()
boolean
isValidWorkstation()
void
notifyConnected(MessageChannel channel)
void
notifyDisconnected(MessageChannel channel)
void
onShutdown()
Stops any ongoing processes running as part of the project running in this session.protected void
onStartup()
void
receive(MessageChannel channel, java.lang.String protocol, java.io.Reader payload)
void
setRecentBytesSent(java.lang.Long recentBytesSent)
void
validate(java.lang.String challengeResponse)
Received challenge response from mobile devicevoid
valueBound(javax.servlet.http.HttpSessionBindingEvent event)
void
valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
-
-
-
Field Detail
-
SESSION_KEY
public static final java.lang.String SESSION_KEY
This is the name ( "perspective-session" ) used to store this object on an HttpSession- See Also:
- Constant Field Values
-
context
public final PerspectiveContext context
-
id
public final java.lang.String id
id of the parent HttpSession that owns us
-
uuid
public final java.lang.String uuid
UUID to help keep track of sessions by session monitor.
-
scope
public final SessionScope scope
"scope" of this session - Client or Designer
-
-
Method Detail
-
getGson
public com.inductiveautomation.ignition.common.gson.Gson getGson()
-
getLocale
public java.util.Locale getLocale()
Returns the preferredLocale
that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.- Returns:
- the preferred
Locale
for the client
-
isValidMobile
public boolean isValidMobile()
-
isValidWorkstation
public boolean isValidWorkstation()
-
isBrokeredAuth
public boolean isBrokeredAuth()
-
getDevice
public NativeDevice getDevice()
-
validate
public void validate(@Nullable java.lang.String challengeResponse)
Received challenge response from mobile device
-
getLocales
public java.util.List<java.util.Locale> getLocales()
Returns aList
ofLocale
objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header in the request which created this session. If the client request doesn't provide an Accept-Language header, this method returns aList
containing oneLocale
, the default locale for the server.- Returns:
- a
List
of preferredLocale
objects for the client
-
getOrCreateSession
@Nonnull public InternalSession getOrCreateSession(@Nonnull java.lang.String projectName)
Fetch theInternalSession
associated with the given project name and version or create one if it does not exist in this session collection.- Parameters:
projectName
- the project name- Returns:
- the
InternalSession
associated with the given project name and version in a running state
-
getOrCreateSession
@Nonnull public InternalSession getOrCreateSession(@Nonnull java.lang.String projectName, java.util.UUID sessionId)
-
findProjectSession
@Nonnull public java.util.Optional<InternalSession> findProjectSession(@Nonnull java.lang.String project)
-
getScope
public SessionScope getScope()
-
getContext
public PerspectiveContext getContext()
-
valueBound
public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
- Specified by:
valueBound
in interfacejavax.servlet.http.HttpSessionBindingListener
-
valueUnbound
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
- Specified by:
valueUnbound
in interfacejavax.servlet.http.HttpSessionBindingListener
-
onStartup
protected void onStartup()
- Specified by:
onStartup
in classAbstractLifecycle
-
onShutdown
public void onShutdown()
Stops any ongoing processes running as part of the project running in this session.- Specified by:
onShutdown
in classAbstractLifecycle
-
notifyConnected
public void notifyConnected(MessageChannel channel)
-
notifyDisconnected
public void notifyDisconnected(MessageChannel channel)
-
receive
public void receive(MessageChannel channel, java.lang.String protocol, java.io.Reader payload)
-
handleLogs
public void handleLogs(LogMessage log)
Called when the client has POSTed log messages back to the server.
-
builder
@Nonnull public static PerspectiveSessionCollection.Builder builder()
-
getSecurityZones
@Nonnull public com.google.common.collect.ImmutableCollection<java.lang.String> getSecurityZones()
-
getTotalBytesSent
public java.math.BigInteger getTotalBytesSent()
-
getRecentBytesSent
public java.lang.Long getRecentBytesSent()
-
setRecentBytesSent
public void setRecentBytesSent(java.lang.Long recentBytesSent)
-
-