com.vaadin.collaborationengine.
Class MessageManager
- java.lang.Object
-
- com.vaadin.collaborationengine.AbstractCollaborationManager
-
- com.vaadin.collaborationengine.MessageManager
-
public class MessageManager extends AbstractCollaborationManager
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.collaborationengine.AbstractCollaborationManager
AbstractCollaborationManager.ActivationHandler
-
-
Constructor Summary
Constructors Constructor Description MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationEngine collaborationEngine)
Creates a new manager for the given connection context.
MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, CollaborationEngine collaborationEngine)
Creates a new persisting 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
All Methods Modifier and Type Method Description void
setMessageHandler(MessageHandler handler)
Sets a handler which will be invoked for all messages already in the topic and when a new message is submitted.
CompletableFuture<Void>
submit(CollaborationMessage message)
Submits a message to the topic.
CompletableFuture<Void>
submit(String text)
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 Detail
-
MessageManager
public MessageManager(Component component, UserInfo localUser, String topicId)
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
public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationEngine collaborationEngine)
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
collaborationEngine
- the collaboration engine instance to use, notnull
-
MessageManager
public MessageManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationMessagePersister persister, CollaborationEngine collaborationEngine)
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 sourcecollaborationEngine
- the collaboration engine instance to use, notnull
-
-
Method Detail
-
setMessageHandler
public void setMessageHandler(MessageHandler handler)
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
public CompletableFuture<Void> submit(String text)
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
public CompletableFuture<Void> submit(CollaborationMessage message)
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
-
-