use of com.yellowmessenger.sdk.events.TypingEvent in project yellowmessenger-sdk by yellowmessenger.
the class XMPPService method processMessage.
private void processMessage(String sender, String message) {
String name = PreferencesManager.getInstance(getApplicationContext()).getBusinessName(sender);
ChatResponse chatResponse = null;
try {
chatResponse = gson.fromJson(message, ChatResponse.class);
} catch (Exception e) {
// e.printStackTrace();
}
if (chatResponse != null) {
if (chatResponse.getTyping() != null) {
if (XMPPService.this.username != null && sender.toLowerCase().equals(XMPPService.this.username.toLowerCase())) {
Log.d("Event posting: ", message);
EventBus.getDefault().post(new TypingEvent(sender, chatResponse.getTyping()));
}
}
if (chatResponse.isValid()) {
ChatMessage chatMessage = new ChatMessage(sender, message, sender, false);
chatMessage.save();
if (XMPPService.this.username != null && sender.toLowerCase().equals(XMPPService.this.username.toLowerCase())) {
Log.d("Event posting: ", message);
EventBus.getDefault().post(new MessageReceivedEvent(chatMessage));
}
}
if (chatResponse.getTyping() == null && !(XMPPService.this.username != null && sender.toLowerCase().equals(XMPPService.this.username.toLowerCase()))) {
notifyMessage(sender, name, "...");
}
} else {
processXMPPMessage(sender, name, message);
}
}
Aggregations