Search in sources :

Example 11 with SendingQueueCache

use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method moveFromSendingQueueToWaitQueue.

private void moveFromSendingQueueToWaitQueue(String uniqueId) {
    SendingQueueCache queueCache;
    if (cache) {
        // messageDatabaseHelper.moveFromSendQueueToWaitQueue(uniqueId);
        dataSource.moveFromSendingToWaitingQueue(uniqueId);
    } else {
        queueCache = sendingQList.get(uniqueId);
        if (queueCache != null) {
            WaitQueueCache waitMessageQueue = getWaitQueueCacheFromSendQueue(queueCache, uniqueId);
            waitQList.put(uniqueId, waitMessageQueue);
        }
    }
}
Also used : SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache)

Example 12 with SendingQueueCache

use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.

the class MessageManager method getSendingFromWaitingMessage.

public static SendingQueueCache getSendingFromWaitingMessage(WaitQueueCache waitQueueCache) {
    SendingQueueCache sendingQueueCache = new SendingQueueCache();
    sendingQueueCache.setAsyncContent(waitQueueCache.getAsyncContent());
    sendingQueueCache.setId(waitQueueCache.getId());
    sendingQueueCache.setMessage(waitQueueCache.getMessage());
    sendingQueueCache.setMetadata(waitQueueCache.getMetadata());
    sendingQueueCache.setThreadId(waitQueueCache.getThreadId());
    sendingQueueCache.setUniqueId(waitQueueCache.getUniqueId());
    sendingQueueCache.setSystemMetadata(waitQueueCache.getSystemMetadata());
    return sendingQueueCache;
}
Also used : SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache)

Example 13 with SendingQueueCache

use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.

the class MessageManager method getSendingFromSendingCache.

public static List<Sending> getSendingFromSendingCache(List<SendingQueueCache> listCaches) {
    List<Sending> listQueues = new ArrayList<>();
    for (SendingQueueCache queueCache : listCaches) {
        Sending sending = new Sending();
        sending.setThreadId(queueCache.getThreadId());
        MessageVO messageVO = new MessageVO();
        messageVO.setId(queueCache.getId());
        messageVO.setMessage(queueCache.getMessage());
        messageVO.setMessageType(queueCache.getMessageType());
        messageVO.setMetadata(queueCache.getMetadata());
        messageVO.setSystemMetadata(queueCache.getSystemMetadata());
        sending.setMessageVo(messageVO);
        sending.setUniqueId(queueCache.getUniqueId());
        listQueues.add(sending);
    }
    return listQueues;
}
Also used : SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) Sending(com.fanap.podchat.cachemodel.queue.Sending) ArrayList(java.util.ArrayList) MessageVO(com.fanap.podchat.mainmodel.MessageVO)

Example 14 with SendingQueueCache

use of com.fanap.podchat.cachemodel.queue.SendingQueueCache in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest method checkSendingQueue.

@Test
public void checkSendingQueue() {
    populateThreadsListFromServerOnly();
    assert threads.size() > 0;
    Thread thread = threads.get(0);
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    chat.closeChat();
    sleep(2000);
    Assert.assertNotEquals(chat.getChatState(), CHAT_READY);
    RequestMessage request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    String uniqueId = chat.sendTextMessage(request, null);
    List<SendingQueueCache> sendQ = chat.getSendingQ();
    Assert.assertTrue(sendQ.stream().anyMatch(sendingQueueCache -> sendingQueueCache.getUniqueId().equals(uniqueId)));
}
Also used : SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) ResultThreads(com.fanap.podchat.model.ResultThreads) Context(android.content.Context) ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) BeforeClass(org.junit.BeforeClass) SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) Mock(org.mockito.Mock) Date(java.util.Date) Thread(com.fanap.podchat.mainmodel.Thread) RunWith(org.junit.runner.RunWith) ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) ChatContract(com.example.chat.application.chatexample.ChatContract) ChatResponse(com.fanap.podchat.model.ChatResponse) ArrayList(java.util.ArrayList) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) R(com.fanap.podchat.example.R) ResultHistory(com.fanap.podchat.model.ResultHistory) Looper(android.os.Looper) BaseApplication(com.example.chat.application.chatexample.BaseApplication) ChatActivity(com.example.chat.application.chatexample.ChatActivity) RequestThread(com.fanap.podchat.requestobject.RequestThread) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) Before(org.junit.Before) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) CHAT_READY(com.fanap.podchat.util.ChatStateType.ChatSateConstant.CHAT_READY) ActivityTestRule(android.support.test.rule.ActivityTestRule) Test(org.junit.Test) InstrumentationRegistry(android.support.test.InstrumentationRegistry) AndroidJUnit4(android.support.test.runner.AndroidJUnit4) ChatListener(com.fanap.podchat.chat.ChatListener) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) Mockito(org.mockito.Mockito) APP_ID(com.example.chat.application.chatexample.ChatActivity.APP_ID) List(java.util.List) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) ResultMessage(com.fanap.podchat.model.ResultMessage) Rule(org.junit.Rule) TextMessageType(com.fanap.podchat.util.TextMessageType) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) Date(java.util.Date) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test)

Aggregations

SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)14 WaitQueueCache (com.fanap.podchat.cachemodel.queue.WaitQueueCache)4 JsonObject (com.google.gson.JsonObject)4 MessageVO (com.fanap.podchat.mainmodel.MessageVO)3 ArrayList (java.util.ArrayList)3 ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Looper (android.os.Looper)1 InstrumentationRegistry (android.support.test.InstrumentationRegistry)1 ActivityTestRule (android.support.test.rule.ActivityTestRule)1 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)1 BaseApplication (com.example.chat.application.chatexample.BaseApplication)1 ChatActivity (com.example.chat.application.chatexample.ChatActivity)1 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)1 ChatContract (com.example.chat.application.chatexample.ChatContract)1 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)1 Sending (com.fanap.podchat.cachemodel.queue.Sending)1 Chat (com.fanap.podchat.chat.Chat)1 ChatListener (com.fanap.podchat.chat.ChatListener)1