Search in sources :

Example 6 with WaitQueueCache

use of com.fanap.podchat.cachemodel.queue.WaitQueueCache 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 7 with WaitQueueCache

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

the class MessageManager method getFailedFromWaiting.

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

Example 8 with WaitQueueCache

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

the class MessageManager method getWaitingFromSendingMessage.

public static WaitQueueCache getWaitingFromSendingMessage(@NonNull SendingQueueCache sendingQueue) {
    WaitQueueCache waitMessageQueue = new WaitQueueCache();
    waitMessageQueue.setUniqueId(sendingQueue.getUniqueId());
    waitMessageQueue.setId(sendingQueue.getId());
    waitMessageQueue.setAsyncContent(sendingQueue.getAsyncContent());
    waitMessageQueue.setMessage(sendingQueue.getMessage());
    waitMessageQueue.setThreadId(sendingQueue.getThreadId());
    waitMessageQueue.setMessageType(sendingQueue.getMessageType());
    waitMessageQueue.setSystemMetadata(sendingQueue.getSystemMetadata());
    waitMessageQueue.setMetadata(sendingQueue.getMetadata());
    return waitMessageQueue;
}
Also used : WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache)

Example 9 with WaitQueueCache

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

the class MemoryDataSource method insertToWaitingQueue.

private void insertToWaitingQueue(SendingQueueCache sendingMessage) {
    WaitQueueCache waitingMessage = MessageManager.getWaitingFromSendingMessage(sendingMessage);
    insert(waitQueue, waitingMessage);
}
Also used : WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache)

Example 10 with WaitQueueCache

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

the class TextMessagesQueueTest method movingMessageFromWaitingQToSendingQ.

@Test
public void movingMessageFromWaitingQToSendingQ() {
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    List<WaitQueueCache> waitList = chat.getWaitingQ();
    WaitQueueCache wToSend = waitList.remove(0);
    chat.resendMessage(wToSend.getUniqueId());
    sleep(1000);
    Assert.assertTrue(chat.getWaitingQ().stream().noneMatch(waitQueueCache -> waitQueueCache.getUniqueId().equals(wToSend.getUniqueId())));
}
Also used : 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) ChatListener(com.fanap.podchat.chat.ChatListener) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) Test(org.junit.Test)

Aggregations

WaitQueueCache (com.fanap.podchat.cachemodel.queue.WaitQueueCache)12 SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)5 ChatListener (com.fanap.podchat.chat.ChatListener)3 MessageVO (com.fanap.podchat.mainmodel.MessageVO)3 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Looper (android.os.Looper)2 InstrumentationRegistry (android.support.test.InstrumentationRegistry)2 ActivityTestRule (android.support.test.rule.ActivityTestRule)2 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)2 BaseApplication (com.example.chat.application.chatexample.BaseApplication)2 ChatActivity (com.example.chat.application.chatexample.ChatActivity)2 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)2 ChatContract (com.example.chat.application.chatexample.ChatContract)2 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)2 Chat (com.fanap.podchat.chat.Chat)2 R (com.fanap.podchat.example.R)2