Package com.bitheads.braincloud.services
Class ChatService
java.lang.Object
com.bitheads.braincloud.services.ChatService
public class ChatService extends Object
Created by bradleyh on 5/6/2016.
-
Constructor Summary
Constructors Constructor Description ChatService(BrainCloudClient client) -
Method Summary
Modifier and Type Method Description voidchannelConnect(String channelId, int maxReturn, IServerCallback callback)Registers a listener for incoming events from channelId.voidchannelDisconnect(String channelId, IServerCallback callback)Unregisters a listener for incoming events from channelId.voiddeleteChatMessage(String channelId, String msgId, int version, IServerCallback callback)Delete a chat message.voidgetChannelId(String channelType, String channelSubId, IServerCallback callback)Gets the channelId for the given channelType and channelSubId.voidgetChannelInfo(String channelId, IServerCallback callback)Gets description info and activity stats for channel channelId.voidgetChatMessage(String channelId, String msgId, IServerCallback callback)Gets a populated chat object (normally for editing).voidgetRecentChatMessages(String channelId, int maxReturn, IServerCallback callback)Get a list of maxReturn messages from history of channel channelId.voidgetSubscribedChannels(String channelType, IServerCallback callback)Gets a list of the channels of type channelType that the user has access to.voidpostChatMessage(String channelId, String text, String rich, Boolean recordInHistory, IServerCallback callback)Send a potentially rich chat message.voidpostChatMessageSimple(String channelId, String text, Boolean recordInHistory, IServerCallback callback)Send a plaiin text message Service Name - Chat Service Operation - postChatMessageSimplevoidupdateChatMessage(String channelId, String msgId, int version, String text, String rich, IServerCallback callback)Update a chat message.
-
Constructor Details
-
ChatService
-
-
Method Details
-
channelConnect
Registers a listener for incoming events from channelId. Also returns a list of maxReturn recent messages from history. Service Name - Chat Service Operation - ChannelConnect- Parameters:
channelId- The id of the chat channel to return history from.maxReturn- Maximum number of messages to return.callback- The method to be invoked when the server response is received
-
channelDisconnect
Unregisters a listener for incoming events from channelId. Service Name - Chat Service Operation - channelDisconnect- Parameters:
channelId- The id of the chat channel to unsubscribed from.callback- The method to be invoked when the server response is received
-
deleteChatMessage
public void deleteChatMessage(String channelId, String msgId, int version, IServerCallback callback)Delete a chat message. Version must match the latest or pass -1 to bypass version check. Service Name - Chat Service Operation - deleteChatMessage- Parameters:
channelId- The id of the chat channel that contains the message to delete.msgId- The message id to delete.version- Version of the message to delete. Must match latest or pass -1 to bypass version check.callback- The method to be invoked when the server response is received
-
getChannelId
Gets the channelId for the given channelType and channelSubId. Channel type must be one of "gl" or "gr". Service Name - Chat Service Operation - getChannelId- Parameters:
channelType- Channel type must be one of "gl" or "gr". For (global) or (group) respectively.channelSubId- The sub id of the channel.callback- The method to be invoked when the server response is received
-
getChannelInfo
Gets description info and activity stats for channel channelId. Note that numMsgs and listeners only returned for non-global groups. Only callable for channels the user is a member of. Service Name - Chat Service Operation - getChannelInfo- Parameters:
channelId- Id of the channel to receive the info from.callback- The method to be invoked when the server response is received.
-
getChatMessage
Gets a populated chat object (normally for editing). Service Name - Chat Service Operation - getChatMessage- Parameters:
channelId- Id of the channel to receive the message from.msgId- Id of the message to read.callback- The method to be invoked when the server response is received.
-
getRecentChatMessages
Get a list of maxReturn messages from history of channel channelId. Service Name - Chat Service Operation - GET_RECENT_CHAT_MESSAGES- Parameters:
channelId- Id of the channel to receive the info from.maxReturn- Maximum message count to return.callback- The method to be invoked when the server response is received.
-
getSubscribedChannels
Gets a list of the channels of type channelType that the user has access to. Channel type must be one of "gl", "gr" or "all". Service Name - Chat Service Operation - getSubscribedChannels- Parameters:
channelType- Type of channels to get back. "gl" for global, "gr" for group or "all" for both.callback- The method to be invoked when the server response is received.
-
postChatMessage
public void postChatMessage(String channelId, String text, String rich, Boolean recordInHistory, IServerCallback callback)Send a potentially rich chat message. Content must contain at least a "plain" field for plain-text messaging. Service Name - Chat Service Operation - postChatMessage- Parameters:
channelId- Channel id to post message to.text- the text message.rich- custom data.recordInHistory- true if the message persist in historycallback- The method to be invoked when the server response is received.
-
postChatMessageSimple
public void postChatMessageSimple(String channelId, String text, Boolean recordInHistory, IServerCallback callback)Send a plaiin text message Service Name - Chat Service Operation - postChatMessageSimple- Parameters:
channelId- Channel id to post message to.text- the text message.recordInHistory- true if the message persist in historycallback- The method to be invoked when the server response is received.
-
updateChatMessage
public void updateChatMessage(String channelId, String msgId, int version, String text, String rich, IServerCallback callback)Update a chat message. content must contain at least a "plain" field for plain-text messaging. Service Name - Chat Service Operation - updateChatMessage- Parameters:
channelId- Channel id where the message to update is.msgId- Message id to update.version- Version of the message to update. Must match latest or pass -1 to bypass version check.text- the text message.rich- custom data.callback- The method to be invoked when the server response is received.
-