com.vaadin.collaborationengine.
Class MessageManager
All Implemented Interfaces:
Manager to handle messages sent to a topic. It allows submitting messages to a topic and set a handler to react when a new message has been submitted.
Author:
Vaadin Ltd
See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.collaborationengine.AbstractCollaborationManager
AbstractCollaborationManager.ActivationHandler
-
Constructor Summary
ConstructorsConstructorDescriptionMessageManager
(ConnectionContext context, UserInfo localUser, String topicId, CollaborationEngine collaborationEngine) Deprecated, for removal: This API element is subject to removal in a future version.
This constructor is not compatible with serializationMessageManager
(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, CollaborationEngine collaborationEngine) Deprecated, for removal: This API element is subject to removal in a future version.
This constructor is not compatible with serializationMessageManager
(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, SerializableSupplier<CollaborationEngine> ceSupplier) Creates a new persisting manager for the given connection context.
MessageManager
(ConnectionContext context, UserInfo localUser, String topicId, SerializableSupplier<CollaborationEngine> ceSupplier) Creates a new manager for the given connection context.
MessageManager
(Component component, UserInfo localUser, String topicId) Creates a new manager for the given component.
MessageManager
(Component component, UserInfo localUser, String topicId, CollaborationMessagePersister persister) Creates a new persisting manager for the given component.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setMessageHandler
(MessageHandler handler) Sets a handler which will be invoked for all messages already in the topic and when a new message is submitted.
submit
(CollaborationMessage message) Submits a message to the topic.
Submits a message to the topic as the current local user.
Methods inherited from class com.vaadin.collaborationengine.AbstractCollaborationManager
close, getCollaborationEngine, getLocalUser, getTopicId, onConnectionFailed, openTopicConnection, setActivationHandler
-
Constructor Details
-
MessageManager
Creates a new manager for the given component.
Parameters:
component
- the component which holds UI access, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
-
MessageManager
public MessageManager(Component component, UserInfo localUser, String topicId, CollaborationMessagePersister persister) Creates a new persisting manager for the given component.
Parameters:
component
- the component which holds UI access, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
persister
- the persister to read/write messages to an external source -
MessageManager
@Deprecated(since="6.1", forRemoval=true) public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationEngine collaborationEngine) Deprecated, for removal: This API element is subject to removal in a future version.This constructor is not compatible with serializationCreates a new manager for the given connection context.
Parameters:
context
- the context that manages connection status, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
collaborationEngine
- the collaboration engine instance to use, notnull
-
MessageManager
public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, SerializableSupplier<CollaborationEngine> ceSupplier) Creates a new manager for the given connection context.
Parameters:
context
- the context that manages connection status, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
ceSupplier
- the collaboration engine instance to use, notnull
-
MessageManager
@Deprecated(since="6.1", forRemoval=true) public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, CollaborationEngine collaborationEngine) Deprecated, for removal: This API element is subject to removal in a future version.This constructor is not compatible with serializationCreates a new persisting manager for the given connection context.
Parameters:
context
- the context that manages connection status, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
persister
- the persister to read/write messages to an external sourcecollaborationEngine
- the collaboration engine instance to use, notnull
-
MessageManager
public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, SerializableSupplier<CollaborationEngine> ceSupplier) Creates a new persisting manager for the given connection context.
Parameters:
context
- the context that manages connection status, notnull
localUser
- the information of the local user, notnull
topicId
- the id of the topic to connect to, notnull
persister
- the persister to read/write messages to an external sourceceSupplier
- the collaboration engine instance to use, notnull
-
-
Method Details
-
setMessageHandler
Sets a handler which will be invoked for all messages already in the topic and when a new message is submitted.
The handler accepts a
MessageHandler.MessageContext
as a parameter which contains a reference to the sent message.Parameters:
handler
- the message handler, ornull
to remove an existing handler -
submit
Submits a message to the topic as the current local user.
Parameters:
text
- the text of the message, notnull
Returns:
a future which will complete when the message has been added to the topic, not
null
-
submit
Submits a message to the topic.
Parameters:
message
- the message, notnull
Returns:
a future which will complete when the message has been added to the topic, not
null
-