public class MessageService
extends java.lang.Object
The service exposes methods for retrieving messages for a given stream or user historically.
The service provides convenience methods to support the sending of messages using standard models (Chat, Room)
The service converts all base messages to SymMessage
.
Multiple listeners of different types can be registered at any time.
MessageListener - Listen for all messages ChatListener - Listen for chat conversations (1:1 or multi-party) RoomServiceListener - Listen for all Room related events.
Constructor and Description |
---|
MessageService(SymphonyClient symClient)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addChatListener(ChatListener chatListener)
Add
ChatListener to receive new conversation chat messages |
void |
addConnectionsEventListener(ConnectionsEventListener connectionsEventListener)
Add
ConnectionsEventListener to service to receive new Connection events |
void |
addMessageListener(MessageListener messageListener)
Add
MessageListener to receive for all new messages |
void |
addRoomServiceEventListener(RoomServiceEventListener roomServiceEventListener)
Add
RoomServiceEventListener to service to receive new Room events |
java.util.List<SymMessage> |
getMessagesFromUserId(long userId,
java.lang.Long since,
java.lang.Integer offset,
java.lang.Integer maxMessages)
Retrieve messages for a given user ID based on window of time
|
void |
onEvent(SymEvent symEvent)
Listen to all events from datafeed polling
This is only enabled when V4+ API is being used.
|
boolean |
removeChatListener(ChatListener chatListener)
Remove a registered chat listener
|
boolean |
removeConnectionsEventListener(ConnectionsEventListener connectionsEventListener)
Remove connections event listener from service
|
boolean |
removeMessageListener(MessageListener messageListener)
Remove a registered
MessageListener t |
boolean |
removeRoomServiceEventListener(RoomServiceEventListener roomServiceEventListener)
Remove room event listener from service
|
SymMessage |
sendMessage(Chat chat,
SymMessage symMessage)
Convenience method for sending messages to chat conversation (1:1 or Multi-party)
|
SymMessage |
sendMessage(Room room,
SymMessage symMessage)
Convenience method for sending messages to a room
|
SymMessage |
sendMessage(java.lang.String email,
SymMessage symMessage)
Convenience method to send a message to a given user by email address
|
SymMessage |
sendMessage(SymStream symStream,
SymMessage symMessage)
Send a message to a given stream
|
SymMessage |
sendMessage(SymUser symUser,
SymMessage symMessage)
Send a message to a given user
|
void |
shutdown()
Shutdown the underlying threads and workers.
|
public MessageService(SymphonyClient symClient)
symClient
- Identifies the BOT user and exposes client APIspublic SymMessage sendMessage(Room room, SymMessage symMessage) throws MessagesException
room
- Room objectsymMessage
- Message to send to the roomMessagesException
- Generated from API calls into Symphonypublic SymMessage sendMessage(Chat chat, SymMessage symMessage) throws MessagesException
chat
- Chat object representing conversationsymMessage
- Message to send to the conversationMessagesException
- Generated from API calls into Symphonypublic SymMessage sendMessage(java.lang.String email, SymMessage symMessage) throws MessagesException
email
- email of destination usersymMessage
- Message to sendMessagesException
- Generated from API calls into Symphonypublic SymMessage sendMessage(SymUser symUser, SymMessage symMessage) throws MessagesException
symUser
- User to send message tosymMessage
- Message to sendMessagesException
- Generated from API calls into Symphonypublic SymMessage sendMessage(SymStream symStream, SymMessage symMessage) throws MessagesException
symStream
- Stream to send message tosymMessage
- Message to sendMessagesException
- Generated from API calls into Symphonypublic java.util.List<SymMessage> getMessagesFromUserId(long userId, java.lang.Long since, java.lang.Integer offset, java.lang.Integer maxMessages) throws MessagesException
userId
- A userId (long value)since
- Starting point date (long value)offset
- (Optional) No. of messages to skip.maxMessages
- (Optional) Maximum number of messages to retrieve from the starting pointList
List of messagesMessagesException
- Generated from API calls into Symphonypublic void onEvent(SymEvent symEvent)
symEvent
- Events received from datafeed pollingpublic void addMessageListener(MessageListener messageListener)
MessageListener
to receive for all new messagesmessageListener
- listener that will be notified of eventspublic boolean removeMessageListener(MessageListener messageListener)
MessageListener
tmessageListener
- listener that will removed from servicepublic void addRoomServiceEventListener(RoomServiceEventListener roomServiceEventListener)
RoomServiceEventListener
to service to receive new Room eventsroomServiceEventListener
- listener to registerpublic boolean removeRoomServiceEventListener(RoomServiceEventListener roomServiceEventListener)
roomServiceEventListener
- listener to removepublic void addConnectionsEventListener(ConnectionsEventListener connectionsEventListener)
ConnectionsEventListener
to service to receive new Connection eventsconnectionsEventListener
- listener to registerpublic boolean removeConnectionsEventListener(ConnectionsEventListener connectionsEventListener)
connectionsEventListener
- listener to removepublic void addChatListener(ChatListener chatListener)
ChatListener
to receive new conversation chat messageschatListener
- listener to registerpublic boolean removeChatListener(ChatListener chatListener)
chatListener
- listener to removepublic void shutdown()