-
Notifications
You must be signed in to change notification settings - Fork 37
Chat Service
The chat service provides capabilities to manage chat sessions dynamically through use of standard Chat objects and registered listeners. The service can detect unique chat sessions on the network and publish the associated chat objects through registered listeners. The service will keep a cache of chat objects (lazy loaded) that are accessible through the service. Chat objects are automatically enriched with all chat participant detail (SymUser).
The chat service is accessible through a instantiated SymphonyClient instance.
//From SymphonyClient symClient...
//...
symClient.getChatService();
The chat service listener can be registered to the chat service in order to receive callbacks on new chat objects created and removed. Again, chat objects received are fully enriched with user data. The chat service listener only provides events on the creation or termination of new chat objects.
class MyChatManager implements ChatServiceListener{
SymphonyClient symClient;
public MyChatManager(SymphonyClient symClient){
this.symClient = symClient;
//Will notify the bot of new Chat conversations.
symClient.getChatService().addListener(this);
}
@Override
public onNewChat(Chat chat){
//New chat object received dynamically
}
@Override
public onChatRemoved(Chat chat){
//Service removed chat
}
}
The chat object manages all properties of the chat conversation or in Symphony terminology the stream. Each chat object can support many listeners that act as callbacks for conversation messages.
The chat object includes the following attributes
- RemoteUsers (Set of SymUser) - All users that are participating in the conversation (excluding the BOT User)
- LocalUser (SymUser) - The BOT user
- Stream (Stream) - The stream object representing the conversation
- StreamId (String) - The stream ID that represents the conversation (Note: setting stream object will set stream ID)
- LastMessage (SymMessage) - Last message published in the conversation
- ChatListeners (Set of ChatListeners) - Listeners that receive the published message