use of com.fanap.podchat.util.Callback in project pod-chat-android-sdk by FanapSoft.
the class DbTest method justFirstMsgIdC3.
@Test
public void justFirstMsgIdC3() {
Callback callback = new Callback();
long threadId = 2;
callback.setOffset(0);
callback.setCount(2);
callback.setOrder("asc");
callback.setFirstMessageId(9236);
// MessageVO messageVO = new MessageVO(
// 5653,
// false,
// false,
// false,
// false,
// false,
// "91efe7da-547f-4c5f-c34b-0442951ffbbc",
// 0,
// 5652,
// "",
// null,
// 13354321,
// 321000000,
// "",
// null,
// null,
// null,
// null
// );
// messageDatabaseHelper.updateGetHistoryResponse(callback);
}
use of com.fanap.podchat.util.Callback in project pod-chat-android-sdk by FanapSoft.
the class DbTest method updateCacheFirstMsgIdAndLastMsgIdConditional2.
// first messsage and last message
// Conditional 2
// cache siz more than one but server size is 1
@Test
public void updateCacheFirstMsgIdAndLastMsgIdConditional2() {
long threadId = 2;
Callback callback = new Callback();
List<MessageVO> messageVOS = new ArrayList<>();
// MessageVO messageVO = new MessageVO(
// 5653,
// false,
// false,
// false,
// false,
// false,
// "91efe7da-547f-4c5f-c34b-0442951ffbbc",
// 0,
// 5652,
// "",
// null,
// 13354321,
// 321000000,
// "",
// null,
// null,
// null,
// null
//
// );
List<CacheMessageVO> cacheMessageVOS = new ArrayList<>();
CacheMessageVO cacheMessageVO = new CacheMessageVO();
cacheMessageVO.setId(5878);
cacheMessageVO.setThreadVoId(2L);
cacheMessageVOS.add(cacheMessageVO);
// messageVOS.add(messageVO);
callback.setOffset(0);
callback.setOffset(0);
callback.setCount(50);
callback.setOrder("asc");
callback.setFirstMessageId(5652);
callback.setLastMessageId(5878);
messageDatabaseHelper.updateGetHistoryResponse(callback, messageVOS, threadId, cacheMessageVOS);
}
use of com.fanap.podchat.util.Callback in project pod-chat-android-sdk by FanapSoft.
the class DbTest method justFirstMsgIdsetConditional1.
// first message id conditional 1
// cache siz more than one but server size is 1
@Test
public void justFirstMsgIdsetConditional1() {
Callback callback = new Callback();
long threadId = 2;
// MessageVO messageVO = new MessageVO(
// 5653,
// false,
// false,
// false,
// false,
// false,
// "91efe7da-547f-4c5f-c34b-0442951ffbbc",
// 0,
// 5652,
// "",
// null,
// 13354321,
// 321000000,
// "",
// null,
// null,
// null,
// null
// );
callback.setOffset(0);
callback.setCount(2);
callback.setOrder("asc");
callback.setFirstMessageId(9261);
messageDatabaseHelper.updateGetHistoryResponse(callback, null, threadId, null);
}
use of com.fanap.podchat.util.Callback in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method handleDelivery.
private void handleDelivery(ChatMessage chatMessage, String messageUniqueId, long threadId) {
try {
if (threadCallbacks.containsKey(threadId)) {
ArrayList<Callback> callbacks = threadCallbacks.get(threadId);
if (callbacks != null) {
for (Callback callback : callbacks) {
if (messageUniqueId.equals(callback.getUniqueId())) {
int indexUnique = callbacks.indexOf(callback);
while (indexUnique > -1) {
if (callbacks.get(indexUnique).isDelivery()) {
ChatResponse<ResultMessage> chatResponse = new ChatResponse<>();
ResultMessage resultMessage = gson.fromJson(chatMessage.getContent(), ResultMessage.class);
chatResponse.setErrorMessage("");
chatResponse.setErrorCode(0);
chatResponse.setHasError(false);
chatResponse.setUniqueId(callback.getUniqueId());
chatResponse.setResult(resultMessage);
String json = gson.toJson(chatResponse);
listenerManager.callOnDeliveryMessage(json, chatResponse);
Callback callbackUpdateSent = new Callback();
callbackUpdateSent.setSent(callback.isSent());
callbackUpdateSent.setDelivery(false);
callbackUpdateSent.setSeen(callback.isSeen());
callbackUpdateSent.setUniqueId(callback.getUniqueId());
callbacks.set(indexUnique, callbackUpdateSent);
threadCallbacks.put(threadId, callbacks);
if (sentryResponseLog) {
showLog("RECEIVED_DELIVERED_MESSAGE", json);
} else {
showLog("RECEIVED_DELIVERED_MESSAGE");
}
}
indexUnique--;
}
break;
}
}
}
}
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
use of com.fanap.podchat.util.Callback in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method setCallBacks.
private void setCallBacks(long firstMessageId, long lastMessageId, String order, long count, Long offset, String uniqueId, long msgId, boolean messageCriteriaVO, String query) {
try {
if (chatReady || asyncReady) {
offset = offset != null ? offset : 0;
Callback callback = new Callback();
callback.setFirstMessageId(firstMessageId);
callback.setLastMessageId(lastMessageId);
callback.setOffset(offset);
callback.setCount(count);
callback.setOrder(order);
callback.setMessageId(msgId);
callback.setResult(true);
callback.setQuery(query);
callback.setMetadataCriteria(messageCriteriaVO);
callback.setRequestType(Constants.GET_HISTORY);
messageCallbacks.put(uniqueId, callback);
}
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(uniqueId, e);
}
}
Aggregations