use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method generateSendingQueueCache.
public static SendingQueueCache generateSendingQueueCache(long threadId, long messageId, String uniqueId, String typecode, String token) {
SendingQueueCache sendingQueue = new SendingQueueCache();
sendingQueue.setUniqueId(uniqueId);
MessageVO messageVO = new MessageVO();
messageVO.setId(messageId);
messageVO.setUniqueId(uniqueId);
sendingQueue.setThreadId(threadId);
String queueAsyncContent = CreateAsyncContentForQueue(threadId, messageId, uniqueId, typecode, token);
sendingQueue.setAsyncContent(queueAsyncContent);
return sendingQueue;
}
use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method moveFromSendQueueToWaitQueue.
public void moveFromSendQueueToWaitQueue(String uniqueId) {
getThreadManager().doThisSafe(() -> {
SendingQueueCache sendingQueue = getSendingQueueCache(uniqueId);
deleteSendingMessageQueue(uniqueId);
insertWaitMessageQueue(sendingQueue);
});
}
use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method moveFromWaitQueueToSendQueue.
public void moveFromWaitQueueToSendQueue(String uniqueId, OnWorkDone listener) {
getThreadManager().doThisAndGo(() -> {
SendingQueueCache sendingQueue = getWaitQueueMsgByUnique(uniqueId);
deleteWaitQueueMsgs(uniqueId);
insertSendingMessageQueue(sendingQueue);
listener.onWorkDone(sendingQueue);
});
}
use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.
the class MemoryDataSource method moveFromWaitingQueueToSendingQueue.
public Observable<SendingQueueCache> moveFromWaitingQueueToSendingQueue(String uniqueId) {
return Observable.create(em -> {
WaitQueueCache waiting = deleteFromWaitingQueue(uniqueId);
if (null != waiting) {
SendingQueueCache sending = MessageManager.getSendingFromWaitingMessage(waiting);
insertToSendingQueue(sending);
em.onNext(sending);
} else
em.onCompleted();
});
}
use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method mainReplyMessage.
private String mainReplyMessage(String messageContent, long threadId, long messageId, String systemMetaData, Integer messageType, String metaData, String iUniqueId, ChatHandler handler) {
String uniqueId = iUniqueId;
if (iUniqueId == null)
uniqueId = generateUniqueId();
/* Add to sending Queue*/
SendingQueueCache sendingQueue = new SendingQueueCache();
sendingQueue.setSystemMetadata(systemMetaData);
sendingQueue.setMessageType(messageType);
sendingQueue.setThreadId(threadId);
sendingQueue.setUniqueId(uniqueId);
sendingQueue.setMessage(messageContent);
sendingQueue.setMetadata(metaData);
ChatMessage chatMessage = new ChatMessage();
chatMessage.setUniqueId(uniqueId);
chatMessage.setRepliedTo(messageId);
chatMessage.setSubjectId(threadId);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(getToken());
chatMessage.setContent(messageContent);
chatMessage.setMetadata(metaData);
chatMessage.setSystemMetadata(systemMetaData);
chatMessage.setType(Constants.MESSAGE);
chatMessage.setTypeCode(getTypeCode());
chatMessage.setMessageType(messageType);
JsonObject jsonObject = (JsonObject) gson.toJsonTree(chatMessage);
if (Util.isNullOrEmpty(systemMetaData)) {
jsonObject.remove("systemMetaData");
}
if (Util.isNullOrEmpty(metaData)) {
jsonObject.remove("metadata");
}
jsonObject.remove("time");
String asyncContent = jsonObject.toString();
sendingQueue.setAsyncContent(asyncContent);
insertToSendQueue(uniqueId, sendingQueue);
if (log)
Log.i(TAG, "Message with this" + "uniqueId" + uniqueId + "has been added to Message Queue");
if (chatReady) {
moveFromSendingQueueToWaitQueue(uniqueId, sendingQueue);
setThreadCallbacks(threadId, uniqueId);
sendAsyncMessage(asyncContent, AsyncAckType.Constants.WITHOUT_ACK, "SEND_REPLY_MESSAGE");
stopTyping();
if (handler != null) {
handler.onReplyMessage(uniqueId);
}
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
return uniqueId;
}
Aggregations