Class AbstractGatewayConnection
java.lang.Object
com.inductiveautomation.ignition.client.gateway_interface.AbstractGatewayConnection
- All Implemented Interfaces:
GatewayConnection
,GatewayConstants
- Direct Known Subclasses:
ClientGatewayConnection
,DesignerGatewayConnection
public abstract class AbstractGatewayConnection
extends Object
implements GatewayConnection, GatewayConstants
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record
final class
The local endpoint of the WebSocket connection.Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.client.gateway_interface.GatewayConnection
GatewayConnection.Rpc
Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.common.gateway.GatewayConstants
GatewayConstants.ClientAuthChallengeDeserializer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
protected final GatewayConnectionContext
TheGatewayConnectionContext
containing the launch context, thread pools, WebSocket and HTTP clients.static final String
protected static final LoggerEx
Used for internal logging ONLY.protected final ReentrantReadWriteLock
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from interface com.inductiveautomation.ignition.client.gateway_interface.GatewayConnection
CONNECTED, CONNECTION_MODE, CONNECTION_UP, GATEWAY_ADDRESS, GATEWAY_NODE_ROLE, GATEWAY_TIME_ZONE, PROJECT_NAME, ROLES, SESSION_VALID, USERNAME, ZONES
Fields inherited from interface com.inductiveautomation.ignition.common.gateway.GatewayConstants
BUILD_NUMBER, CONNECT_TIMEOUT, ERRNO_BROWSE_ERROR, ERRNO_COMM_ERROR, ERRNO_CONNECTION_MODE, ERRNO_DBCONNECTION_SQL, ERRNO_INTERNAL, ERRNO_INVALIDARGS, ERRNO_INVOCATION_EXCEPTION, ERRNO_LICENSE_RESTRICTED, ERRNO_LOGIN_CANCELLED, ERRNO_LOGIN_FAILED, ERRNO_LOGIN_FAILED_LICENSING, ERRNO_NO_SESSION, ERRNO_NON_ACTIVE_NODE, ERRNO_NON_MASTER_NODE, ERRNO_NOT_AUTHORIZED, ERRNO_OK, ERRNO_PARSE, ERRNO_PASSWORD_EXPIRED, ERRNO_SQL, ERRNO_TRIAL_EXPIRED, ERRNO_VERSION_INCOMPATIBILITY, ERROR_MESSAGE_TYPE, FUNCTION_NAME, GSON, LOCALE_LIST, MODE_DISCONNECTED, MODE_FULL, MODE_READ_ONLY, MODULE_ID, MTYPE_PUBLIC_PING, OPC_BROWSE_TIMEOUT, PACKAGE_ID, PROJECT_NAME, REMOTE_HOST, SCOPE_HEADER, SESSION_ID_HEADER, SOCKET_TIMEOUT, TIMEZONE_ID, WARNING_MESSAGE_TYPE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Different from the ConnectionListener in the sense that this listener is intended for use in redundant setups, where the status of the inactive connection must be updated along with the status of the active connection.void
void
addPropertyChangeListener
(String propName, PropertyChangeListener l) <T> void
addPushNotificationListener
(PushNotificationListener<T> listener, PushNotificationDeserializer<T> deserializer) Adds a handler for push notifications.protected void
protected abstract LoginResult
authChallengeLogin
(GatewayInterface gatewayInterface, AuthChallenge challenge, String projectName) authChallengeLogin
(String projectName, AuthChallenge challenge) void
Connect to the gateway(s) specifiedvoid
protected CompletableFuture<Void>
Fire a collection of push notifications to all listeners.Returns a list of all possible Gateway addresses that are known to the client.The encrypted auth challenge that was used to log inint
Returns the current connection modeint
Returns the address of the gateway that is currently being communicated with.Returns the string version of the currently connected gateway's "Node Role", which will be one of: Independent Master BackupReturns the url to the web portion of the gateway, like "http[s]://<address>:<port>[/context]"int
The number of concurrent HTTP connections allowed.int
The name of the project that we are currently logged into, if any.Get the project name bound to this connection.getRoles()
The set of roles that the actively logged in user has, if any.Returns "http" or "https" depending on our transport schemeprotected abstract int
getScope()
The set of security zones that the actively logged in user has, if any.int
The username of the actively logged in user, if any.protected abstract HandshakeExchange
handshake
(GatewayInterface gatewayInterface) protected abstract LoginResult
idpLoginFinish
(GatewayInterface gatewayInterface, String projectName) idpLoginFinish
(String projectName) protected abstract URI
idpLoginStart
(GatewayInterface gatewayInterface, String projectName) idpLoginStart
(String projectName) boolean
static boolean
boolean
boolean
boolean
void
logout()
protected abstract void
logout
(GatewayInterface gatewayInterface) protected void
onConnect
(GatewayInterface gatewayInterface) protected abstract void
protected abstract void
protected void
operateOnPropertyChangeSupport
(Consumer<PropertyChangeSupport> propertyChangeSupportOperation) Fire an operation against thepropertyChangeSupport
instance on theexecutionQueue
.void
void
void
removePropertyChangeListener
(String propName, PropertyChangeListener l) void
removePushNotificationListener
(PushNotificationListener<?> listener) protected void
void
setConnectionMode
(int newConnectionMode) void
setConnectTimeout
(int newConnectTimeout) void
setHttpConcurrency
(int newHttpConcurrency) void
setOpcBrowseTimeout
(int newOpcBrowseTimeout) void
setSocketTimeout
(int newSocketTimeout) protected abstract LoginResult
tokenLogin
(GatewayInterface gatewayInterface, String encodedAuthToken, String projectName) void
Manually update the status of all connection listeners.void
updateLocale
(Locale newLocale) Sends a message to the gateway indicating that the session's locale changed due to some client action.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.client.gateway_interface.GatewayConnection
addPushNotificationListener
-
Field Details
-
REDUNDANT_MASTER
-
REDUNDANT_BACKUP
-
INDEPENDENT
- See Also:
-
CONNECTING
- See Also:
-
CONNECT_SUCCESS
- See Also:
-
CONNECT_FAIL
- See Also:
-
STATUS_CONNECT_UNKNOWN
public static final int STATUS_CONNECT_UNKNOWN- See Also:
-
STATUS_CONNECTING
public static final int STATUS_CONNECTING- See Also:
-
STATUS_CONNECTED
public static final int STATUS_CONNECTED- See Also:
-
STATUS_CONNECT_FAIL
public static final int STATUS_CONNECT_FAIL- See Also:
-
STATUS_CONNECT_INACTIVE
public static final int STATUS_CONNECT_INACTIVE- See Also:
-
STATUS_CONNECTED_INCOMPATIBLE
public static final int STATUS_CONNECTED_INCOMPATIBLE- See Also:
-
STATUS_CONNECT_WARNING
public static final int STATUS_CONNECT_WARNING- See Also:
-
LOG
-
LOGGER_STATUS_LOOKUP
Used for internal logging ONLY. Do not use to display messages to the user, as these strings are not internationalized. -
readWriteLock
-
context
TheGatewayConnectionContext
containing the launch context, thread pools, WebSocket and HTTP clients.
-
-
Constructor Details
-
AbstractGatewayConnection
-
-
Method Details
-
getScope
protected abstract int getScope() -
updateLocale
Sends a message to the gateway indicating that the session's locale changed due to some client action. -
operateOnPropertyChangeSupport
protected void operateOnPropertyChangeSupport(Consumer<PropertyChangeSupport> propertyChangeSupportOperation) Fire an operation against thepropertyChangeSupport
instance on theexecutionQueue
.- Parameters:
propertyChangeSupportOperation
-Consumer
ofPropertyChangeSupport
which operates on thepropertyChangeSupport
instance while running on theexecutionQueue
-
getProjectNameInternal
Get the project name bound to this connection. Any time we need to log into the Gateway, we need to pass the project name bound to this connection. This method exposes the project name in a scope-dependent way assuming the read or write lock is already held by the caller.- Returns:
- the project name bound to this connection
-
authChallengeLogin
protected abstract LoginResult authChallengeLogin(GatewayInterface gatewayInterface, AuthChallenge challenge, @Nullable String projectName) throws GatewayException - Throws:
GatewayException
-
tokenLogin
protected abstract LoginResult tokenLogin(GatewayInterface gatewayInterface, String encodedAuthToken, @Nullable String projectName) throws GatewayException - Throws:
GatewayException
-
idpLoginFinish
protected abstract LoginResult idpLoginFinish(GatewayInterface gatewayInterface, @Nullable String projectName) throws GatewayException - Throws:
GatewayException
-
authChallengeLogin
public AuthenticatedUser authChallengeLogin(String projectName, AuthChallenge challenge) throws GatewayException - Specified by:
authChallengeLogin
in interfaceGatewayConnection
- Throws:
GatewayException
-
onConnect
-
onUnrecoverableIdpAuthSession
protected abstract void onUnrecoverableIdpAuthSession() -
handshake
-
onVersionMismatch
protected abstract void onVersionMismatch() -
addPushNotificationListeners
protected void addPushNotificationListeners() -
connect
Description copied from interface:GatewayConnection
Connect to the gateway(s) specified- Specified by:
connect
in interfaceGatewayConnection
-
removePushNotificationListeners
protected void removePushNotificationListeners() -
disconnect
public void disconnect()- Specified by:
disconnect
in interfaceGatewayConnection
-
getGatewayAddress
Description copied from interface:GatewayConnection
Returns the address of the gateway that is currently being communicated with.- Specified by:
getGatewayAddress
in interfaceGatewayConnection
-
getAllAddresses
Description copied from interface:GatewayConnection
Returns a list of all possible Gateway addresses that are known to the client. This list includes redundant master and backup addresses. The list is used for client restarts.- Specified by:
getAllAddresses
in interfaceGatewayConnection
-
getGatewayInterface
- Specified by:
getGatewayInterface
in interfaceGatewayConnection
-
getGatewayWebURL
Description copied from interface:GatewayConnection
Returns the url to the web portion of the gateway, like "http[s]://<address>:<port>[/context]"- Specified by:
getGatewayWebURL
in interfaceGatewayConnection
-
getScheme
Description copied from interface:GatewayConnection
Returns "http" or "https" depending on our transport scheme- Specified by:
getScheme
in interfaceGatewayConnection
-
getGatewayNodeRole
Description copied from interface:GatewayConnection
Returns the string version of the currently connected gateway's "Node Role", which will be one of:- Independent
- Master
- Backup
- Specified by:
getGatewayNodeRole
in interfaceGatewayConnection
-
getGatewayTimeZone
- Specified by:
getGatewayTimeZone
in interfaceGatewayConnection
-
idpLoginStart
@Nullable protected abstract URI idpLoginStart(GatewayInterface gatewayInterface, String projectName) throws GatewayException - Throws:
GatewayException
-
idpLoginStart
- Specified by:
idpLoginStart
in interfaceGatewayConnection
- Throws:
GatewayException
-
idpLoginFinish
- Specified by:
idpLoginFinish
in interfaceGatewayConnection
- Throws:
GatewayException
-
logout
-
logout
public void logout()- Specified by:
logout
in interfaceGatewayConnection
-
getConnectionMode
public int getConnectionMode()Description copied from interface:GatewayConnection
Returns the current connection mode- Specified by:
getConnectionMode
in interfaceGatewayConnection
- See Also:
-
setConnectionMode
public void setConnectionMode(int newConnectionMode) - Specified by:
setConnectionMode
in interfaceGatewayConnection
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceGatewayConnection
-
isConnectionUp
public boolean isConnectionUp()- Specified by:
isConnectionUp
in interfaceGatewayConnection
-
isSessionValid
public boolean isSessionValid()- Specified by:
isSessionValid
in interfaceGatewayConnection
-
addPushNotificationListener
public <T> void addPushNotificationListener(PushNotificationListener<T> listener, PushNotificationDeserializer<T> deserializer) Description copied from interface:GatewayConnection
Adds a handler for push notifications. The provided deserializer is used to convert incoming raw binary bytes into your handler's expected message type.- Specified by:
addPushNotificationListener
in interfaceGatewayConnection
- Parameters:
listener
- The listener to add.deserializer
- The deserializer to use.
-
removePushNotificationListener
- Specified by:
removePushNotificationListener
in interfaceGatewayConnection
-
firePushNotification
Fire a collection of push notifications to all listeners. Takes care of firing these on theexecutionQueue
.- Parameters:
n
- the push notifications to fire- Returns:
- a
CompletableFuture
representing the future completion of firing these notification on theexecutionQueue
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in interfaceGatewayConnection
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfaceGatewayConnection
-
addPropertyChangeListener
- Specified by:
addPropertyChangeListener
in interfaceGatewayConnection
-
removePropertyChangeListener
- Specified by:
removePropertyChangeListener
in interfaceGatewayConnection
-
getProjectName
Description copied from interface:GatewayConnection
The name of the project that we are currently logged into, if any.- Specified by:
getProjectName
in interfaceGatewayConnection
-
getUsername
Description copied from interface:GatewayConnection
The username of the actively logged in user, if any.- Specified by:
getUsername
in interfaceGatewayConnection
-
getAuthChallenge
Description copied from interface:GatewayConnection
The encrypted auth challenge that was used to log in- Specified by:
getAuthChallenge
in interfaceGatewayConnection
-
getRoles
Description copied from interface:GatewayConnection
The set of roles that the actively logged in user has, if any.- Specified by:
getRoles
in interfaceGatewayConnection
-
getSecurityZones
Description copied from interface:GatewayConnection
The set of security zones that the actively logged in user has, if any.- Specified by:
getSecurityZones
in interfaceGatewayConnection
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceGatewayConnection
-
setConnectTimeout
public void setConnectTimeout(int newConnectTimeout) - Specified by:
setConnectTimeout
in interfaceGatewayConnection
-
getSocketTimeout
public int getSocketTimeout()- Specified by:
getSocketTimeout
in interfaceGatewayConnection
-
setSocketTimeout
public void setSocketTimeout(int newSocketTimeout) - Specified by:
setSocketTimeout
in interfaceGatewayConnection
-
getOpcBrowseTimeout
public int getOpcBrowseTimeout()- Specified by:
getOpcBrowseTimeout
in interfaceGatewayConnection
-
setOpcBrowseTimeout
public void setOpcBrowseTimeout(int newOpcBrowseTimeout) - Specified by:
setOpcBrowseTimeout
in interfaceGatewayConnection
-
getHttpConcurrency
public int getHttpConcurrency()Description copied from interface:GatewayConnection
The number of concurrent HTTP connections allowed. 0 or less means unlimited.- Specified by:
getHttpConcurrency
in interfaceGatewayConnection
-
setHttpConcurrency
public void setHttpConcurrency(int newHttpConcurrency) - Specified by:
setHttpConcurrency
in interfaceGatewayConnection
-
addConnectionStatusListener
Description copied from interface:GatewayConnection
Different from the ConnectionListener in the sense that this listener is intended for use in redundant setups, where the status of the inactive connection must be updated along with the status of the active connection. The passed ConnectionStatusListener will be continually updated with master/independent and backup connection status every few seconds.- Specified by:
addConnectionStatusListener
in interfaceGatewayConnection
-
removeConnectionStatusListener
- Specified by:
removeConnectionStatusListener
in interfaceGatewayConnection
-
triggerConnectionStatusListeners
public void triggerConnectionStatusListeners()Description copied from interface:GatewayConnection
Manually update the status of all connection listeners. Use this in situations where listeners need an immediate update without waiting for the normal thread task to fire (such as when first displaying a status panel).- Specified by:
triggerConnectionStatusListeners
in interfaceGatewayConnection
-
getEdgeProjectName
- Specified by:
getEdgeProjectName
in interfaceGatewayConnection
- Returns:
- the name of the Edge project as defined by the user on the edge gateway settings
-
isPlatformLicensed
public boolean isPlatformLicensed()- Specified by:
isPlatformLicensed
in interfaceGatewayConnection
-
isConnectionRelated
-