Search in sources :

Example 16 with ResultNewMessage

use of com.fanap.podchat.model.ResultNewMessage in project pod-chat-android-sdk by FanapSoft.

the class ThreadCacheTest method sendMessageAndEdit.

public void sendMessageAndEdit() {
    populateThreadsFromServer();
    Collections.shuffle(threadsInServer);
    Thread thread = threadsInServer.get(0);
    Assert.assertNotNull(thread);
    final long[] messageId = { 0 };
    // send new message
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            messageId[0] = response.getResult().getMessageVO().getId();
            resumeProcess();
            System.out.println("new message sent -> msg : " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestMessage request = new RequestMessage.Builder("Message for test edit :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    chat.sendTextMessage(request, null);
    pauseProcess();
    // delete last message
    chatListeners = new ChatListener() {

        @Override
        public void onEditedMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
            System.out.println("Edited: " + content);
            chat.removeListener(chatListeners);
        }

        @Override
        public void onError(String content, ErrorOutPut error) {
            resumeProcess();
            System.out.println("Error: " + content);
            Assert.assertEquals(0, 1);
            chat.removeListener(chatListeners);
        }
    };
    chat.addListener(chatListeners);
    RequestEditMessage requestEditMessage = new RequestEditMessage.Builder("last message edited " + messageId[0], messageId[0]).build();
    chat.editMessage(requestEditMessage, null);
    pauseProcess();
}
Also used : ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) RequestEditMessage(com.fanap.podchat.requestobject.RequestEditMessage) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) ResultThread(com.fanap.podchat.model.ResultThread)

Example 17 with ResultNewMessage

use of com.fanap.podchat.model.ResultNewMessage in project pod-chat-android-sdk by FanapSoft.

the class HashTagCacheTest method sendHashTagMessage.

public void sendHashTagMessage(long threadId) {
    chatListeners = new ChatListener() {

        @Override
        public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
            resumeProcess();
        }
    };
    RequestMessage request = new RequestMessage.Builder("#test", threadId).messageType(TextMessageType.Constants.TEXT).build();
    chat.setListener(chatListeners);
    chat.sendTextMessage(request, null);
    pauseProcess();
    sleep(6000);
}
Also used : ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener)

Aggregations

ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)17 ChatListener (com.fanap.podchat.chat.ChatListener)10 MessageVO (com.fanap.podchat.mainmodel.MessageVO)8 Thread (com.fanap.podchat.mainmodel.Thread)8 RequestMessage (com.fanap.podchat.requestobject.RequestMessage)8 RequestThread (com.fanap.podchat.requestobject.RequestThread)8 Test (org.junit.Test)6 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)5 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)5 ChatResponse (com.fanap.podchat.model.ChatResponse)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)3 ErrorOutPut (com.fanap.podchat.model.ErrorOutPut)3 ResultHistory (com.fanap.podchat.model.ResultHistory)3 ResultThread (com.fanap.podchat.model.ResultThread)3 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)3 LargeTest (android.support.test.filters.LargeTest)2 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)2 PodChatException (com.fanap.podchat.util.PodChatException)2