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();
}
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);
}
Aggregations