com.vaadin.collaborationengine.
Class CollaborationEngine
- java.lang.Object
-
- com.vaadin.collaborationengine.CollaborationEngine
-
@JsModule(value="./field-highlighter/src/vaadin-field-highlighter.js") public class CollaborationEngine extends Object
CollaborationEngine is an API for creating collaborative experiences in Vaadin applications. It's used by sending and subscribing to changes between collaborators via
collaboration topics
.Use
getInstance()
to get a reference to the singleton object.Author:
Vaadin Ltd
-
-
Method Summary
All Methods Modifier and Type Method and Description static CollaborationEngine
configure(VaadinService vaadinService, CollaborationEngineConfiguration configuration)
Sets the configuration for the Collaboration Engine associated with the given Vaadin service.
static CollaborationEngine
getInstance()
Gets the
CollaborationEngine
instance from the currentVaadinService
.static CollaborationEngine
getInstance(VaadinService vaadinService)
Gets the
CollaborationEngine
instance from the providedVaadinService
.TopicConnectionRegistration
openTopicConnection(Component component, String topicId, UserInfo localUser, SerializableFunction<TopicConnection,Registration> connectionActivationCallback)
Opens a connection to the collaboration topic with the provided id based on a component instance.
TopicConnectionRegistration
openTopicConnection(ConnectionContext context, String topicId, UserInfo localUser, SerializableFunction<TopicConnection,Registration> connectionActivationCallback)
Opens a connection to the collaboration topic with the provided id based on a generic context definition.
void
requestAccess(ConnectionContext context, UserInfo user, Consumer<AccessResponse> requestCallback)
Requests access for a user to Collaboration Engine.
void
requestAccess(UserInfo user, Consumer<AccessResponse> requestCallback)
Requests access for a user to Collaboration Engine.
-
-
-
Method Detail
-
getInstance
public static CollaborationEngine getInstance()
Gets the
CollaborationEngine
instance from the currentVaadinService
.Returns:
the
CollaborationEngine
instance
-
getInstance
public static CollaborationEngine getInstance(VaadinService vaadinService)
Gets the
CollaborationEngine
instance from the providedVaadinService
.Returns:
the
CollaborationEngine
instance
-
configure
public static CollaborationEngine configure(VaadinService vaadinService, CollaborationEngineConfiguration configuration)
Sets the configuration for the Collaboration Engine associated with the given Vaadin service. This configuration is required when running in production mode. It can be set only once.
You should register a
VaadinServiceInitListener
where you call this method with the service returned byServiceInitEvent.getSource()
.Parameters:
vaadinService
- the Vaadin service for which to configure the Collaboration Engineconfiguration
- the configuration to provide for the Collaboration EngineReturns:
the configured Collaboration Engine instance
-
openTopicConnection
public TopicConnectionRegistration openTopicConnection(Component component, String topicId, UserInfo localUser, SerializableFunction<TopicConnection,Registration> connectionActivationCallback)
Opens a connection to the collaboration topic with the provided id based on a component instance. If the topic with the provided id does not exist yet, it's created on demand.
Parameters:
component
- the component which hold UI access, notnull
topicId
- the id of the topic to connect to, notnull
localUser
- the user who is related to the topic connection, aSystemUserInfo
can be used for non-interaction threads. Notnull
.connectionActivationCallback
- the callback to be executed when a connection is activated, notnull
Returns:
the handle that can be used for configuring or closing the connection
-
openTopicConnection
public TopicConnectionRegistration openTopicConnection(ConnectionContext context, String topicId, UserInfo localUser, SerializableFunction<TopicConnection,Registration> connectionActivationCallback)
Opens a connection to the collaboration topic with the provided id based on a generic context definition. If the topic with the provided id does not exist yet, it's created on demand.
Parameters:
context
- context for the connectiontopicId
- the id of the topic to connect to, notnull
localUser
- the user who is related to the topic connection, aSystemUserInfo
can be used for non-interaction threads. Notnull
.connectionActivationCallback
- the callback to be executed when a connection is activated, notnull
Returns:
the handle that can be used for configuring or closing the connection
-
requestAccess
public void requestAccess(UserInfo user, Consumer<AccessResponse> requestCallback)
Requests access for a user to Collaboration Engine. The provided callback will be invoked with a response that tells whether the access is granted.
This method can be used to check if the user has access to the Collaboration Engine, e.g. if the license is not expired and there is quota for that user; depending on the response, it's then possible to adapt the UI enabling or disabling collaboration features.
To avoid calling this method multiple times per user, it is suggested to cache the result during the login process (e.g. in the session).
In the callback, you can check from the response whether the user has access or not with the
AccessResponse.hasAccess()
method. It returnstrue
if access has been granted for the user.The current
UI
is accessed to run the callback, which means that UI updates in the callback are pushed to the client in real-time. Because of depending on the current UI, the method can be called only in the request processing thread, or it will throw.Parameters:
user
- the user requesting accessrequestCallback
- the callback to accept the response
-
requestAccess
public void requestAccess(ConnectionContext context, UserInfo user, Consumer<AccessResponse> requestCallback)
Requests access for a user to Collaboration Engine. The provided callback will be invoked with a response that tells whether the access is granted.
This method can be used to check if the user has access to the Collaboration Engine, e.g. if the license is not expired and there is quota for that user; depending on the response, it's then possible to adapt the UI enabling or disabling collaboration features.
To avoid calling this method multiple times per user, it is suggested to cache the result during the login process (e.g. in the session).
In the callback, you can check from the response whether the user has access or not with the
AccessResponse.hasAccess()
method. It returnstrue
if access has been granted for the user.Parameters:
context
- context for the connectionuser
- the user requesting accessrequestCallback
- the callback to accept the response
-
-