use of com.azure.android.communication.chat.models.ChatMessageEditedEvent in project azure-sdk-for-android by Azure.
the class MainActivity method registerPushNotificationListener.
public void registerPushNotificationListener(View view) {
logAndToast("Register push notification listeners");
try {
chatAsyncClient.addPushNotificationHandler(CHAT_MESSAGE_RECEIVED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_MESSAGE_RECEIVED.");
ChatMessageReceivedEvent event = (ChatMessageReceivedEvent) payload;
Log.i(TAG, "Message received!" + " ThreadId: " + event.getChatThreadId() + " MessageId: " + event.getId() + " Content: " + event.getContent() + " Priority: " + event.getPriority() + " SenderDisplayName: " + event.getSenderDisplayName() + " SenderMri: " + ((CommunicationUserIdentifier) event.getSender()).getId() + " Version: " + event.getVersion() + " CreatedOn: " + event.getCreatedOn() + " Type: " + event.getType() + " RecipientMri: " + ((CommunicationUserIdentifier) event.getRecipient()).getId());
});
chatAsyncClient.addPushNotificationHandler(CHAT_MESSAGE_EDITED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_MESSAGE_EDITED.");
ChatMessageEditedEvent event = (ChatMessageEditedEvent) payload;
Log.i(TAG, "Message edited!" + " ThreadId: " + event.getChatThreadId() + " MessageId: " + event.getId() + " Content: " + event.getContent() + " SenderDisplayName: " + event.getSenderDisplayName() + " SenderMri: " + ((CommunicationUserIdentifier) event.getSender()).getId() + " Version: " + event.getVersion() + " CreatedOn: " + event.getCreatedOn() + " EditedOn: " + event.getEditedOn() + " RecipientMri: " + ((CommunicationUserIdentifier) event.getRecipient()).getId());
});
chatAsyncClient.addPushNotificationHandler(CHAT_MESSAGE_DELETED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_MESSAGE_DELETED.");
ChatMessageDeletedEvent event = (ChatMessageDeletedEvent) payload;
Log.i(TAG, "Message deleted!" + " ThreadId: " + event.getChatThreadId() + " MessageId: " + event.getId() + " SenderDisplayName: " + event.getSenderDisplayName() + " SenderMri: " + ((CommunicationUserIdentifier) event.getSender()).getId() + " Version: " + event.getVersion() + " CreatedOn: " + event.getCreatedOn() + " DeletedOn: " + event.getDeletedOn() + " RecipientMri: " + ((CommunicationUserIdentifier) event.getRecipient()).getId());
});
chatAsyncClient.addPushNotificationHandler(CHAT_THREAD_CREATED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_THREAD_CREATED.");
ChatThreadCreatedEvent event = (ChatThreadCreatedEvent) payload;
Log.i(TAG, "Thread Created!" + " ThreadId: " + event.getChatThreadId() + " Properties_Id: " + event.getProperties().getId() + " Properties_Topic: " + event.getProperties().getTopic() + " Properties_CreatedOn: " + event.getProperties().getCreatedOn() + " Properties_CreatedByMri: " + ((CommunicationUserIdentifier) event.getProperties().getCreatedByCommunicationIdentifier()).getId() + " Participants_size: " + event.getParticipants().size() + " Version: " + event.getVersion() + " CreatedOn: " + event.getCreatedOn() + " CreatedBy_DisplayName: " + event.getCreatedBy().getDisplayName() + " CreatedBy_Mri: " + ((CommunicationUserIdentifier) event.getCreatedBy().getCommunicationIdentifier()).getId());
});
chatAsyncClient.addPushNotificationHandler(CHAT_THREAD_PROPERTIES_UPDATED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_THREAD_PROPERTIES_UPDATED.");
ChatThreadPropertiesUpdatedEvent event = (ChatThreadPropertiesUpdatedEvent) payload;
Log.i(TAG, "Thread Updated!" + " ThreadId: " + event.getChatThreadId() + " Properties_Id: " + event.getProperties().getId() + " Properties_Topic: " + event.getProperties().getTopic() + " Version: " + event.getVersion() + " UpdatedOn: " + event.getUpdatedOn() + " UpdatedBy_DisplayName: " + event.getUpdatedBy().getDisplayName() + " UpdatedBy_Mri: " + ((CommunicationUserIdentifier) event.getUpdatedBy().getCommunicationIdentifier()).getId());
});
chatAsyncClient.addPushNotificationHandler(CHAT_THREAD_DELETED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification CHAT_THREAD_DELETED.");
ChatThreadDeletedEvent event = (ChatThreadDeletedEvent) payload;
Log.i(TAG, "Thread Deleted!" + " ThreadId: " + event.getChatThreadId() + " Version: " + event.getVersion() + " DeletedOn: " + event.getDeletedOn() + " DeletedBy_DisplayName: " + event.getDeletedBy().getDisplayName() + " DeletedBy_Mri: " + ((CommunicationUserIdentifier) event.getDeletedBy().getCommunicationIdentifier()).getId());
});
chatAsyncClient.addPushNotificationHandler(PARTICIPANTS_ADDED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification PARTICIPANTS_ADDED.");
ParticipantsAddedEvent event = (ParticipantsAddedEvent) payload;
Log.i(TAG, "Participant Added!" + " ThreadId: " + event.getChatThreadId() + " ParticipantsAdded_size: " + event.getParticipantsAdded().size() + " Version: " + event.getVersion() + " AddedOn: " + event.getAddedOn() + " AddedBy_DisplayName: " + event.getAddedBy().getDisplayName() + " AddedBy_Mri: " + ((CommunicationUserIdentifier) event.getAddedBy().getCommunicationIdentifier()).getId());
});
chatAsyncClient.addPushNotificationHandler(PARTICIPANTS_REMOVED, (ChatEvent payload) -> {
Log.i(TAG, "Push Notification PARTICIPANTS_REMOVED.");
ParticipantsRemovedEvent event = (ParticipantsRemovedEvent) payload;
Log.i(TAG, "Participant Removed!" + " ThreadId: " + event.getChatThreadId() + " ParticipantsRemoved_size: " + event.getParticipantsRemoved().size() + " Version: " + event.getVersion() + " RemovedOn: " + event.getRemovedOn() + " RemovedBy_DisplayName: " + event.getRemovedBy().getDisplayName() + " RemovedBy_Mri: " + ((CommunicationUserIdentifier) event.getRemovedBy().getCommunicationIdentifier()).getId());
});
} catch (IllegalStateException error) {
Log.i(TAG, "Push Notification not start yet.");
}
}
use of com.azure.android.communication.chat.models.ChatMessageEditedEvent in project azure-sdk-for-android by Azure.
the class MainActivity method registerRealTimeNotificationListener.
public void registerRealTimeNotificationListener(View view) {
logAndToast("Register a test listener");
RealTimeNotificationCallback messageReceivedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatMessageReceivedEvent event = (ChatMessageReceivedEvent) payload;
Log.i(TAG, "Message created! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_MESSAGE_RECEIVED, messageReceivedHandler);
realTimeNotificationCallbacks.put(messageReceivedHandler, CHAT_MESSAGE_RECEIVED);
RealTimeNotificationCallback messageEditedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatMessageEditedEvent event = (ChatMessageEditedEvent) payload;
Log.i(TAG, "Message edited! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_MESSAGE_EDITED, messageEditedHandler);
realTimeNotificationCallbacks.put(messageEditedHandler, CHAT_MESSAGE_EDITED);
RealTimeNotificationCallback messageDeletedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatMessageDeletedEvent event = (ChatMessageDeletedEvent) payload;
Log.i(TAG, "Message deleted! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_MESSAGE_DELETED, messageDeletedHandler);
realTimeNotificationCallbacks.put(messageDeletedHandler, CHAT_MESSAGE_DELETED);
RealTimeNotificationCallback typingIndicatorHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
TypingIndicatorReceivedEvent event = (TypingIndicatorReceivedEvent) payload;
Log.i(TAG, "Typing indicator received! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(TYPING_INDICATOR_RECEIVED, typingIndicatorHandler);
realTimeNotificationCallbacks.put(typingIndicatorHandler, TYPING_INDICATOR_RECEIVED);
RealTimeNotificationCallback readReceiptHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ReadReceiptReceivedEvent event = (ReadReceiptReceivedEvent) payload;
Log.i(TAG, "Read receipt received! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(READ_RECEIPT_RECEIVED, readReceiptHandler);
realTimeNotificationCallbacks.put(readReceiptHandler, READ_RECEIPT_RECEIVED);
RealTimeNotificationCallback threadCreatedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatThreadCreatedEvent event = (ChatThreadCreatedEvent) payload;
Log.i(TAG, "Chat thread created! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_THREAD_CREATED, threadCreatedHandler);
realTimeNotificationCallbacks.put(threadCreatedHandler, CHAT_THREAD_CREATED);
RealTimeNotificationCallback threadDeletedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatThreadDeletedEvent event = (ChatThreadDeletedEvent) payload;
Log.i(TAG, "Chat thread deleted! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_THREAD_DELETED, threadDeletedHandler);
realTimeNotificationCallbacks.put(threadDeletedHandler, CHAT_THREAD_DELETED);
RealTimeNotificationCallback threadUpdatedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ChatThreadPropertiesUpdatedEvent event = (ChatThreadPropertiesUpdatedEvent) payload;
Log.i(TAG, "Chat thread properties updated! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(CHAT_THREAD_PROPERTIES_UPDATED, threadUpdatedHandler);
realTimeNotificationCallbacks.put(threadUpdatedHandler, CHAT_THREAD_PROPERTIES_UPDATED);
RealTimeNotificationCallback participantAddedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ParticipantsAddedEvent event = (ParticipantsAddedEvent) payload;
Log.i(TAG, "Participants added! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(PARTICIPANTS_ADDED, participantAddedHandler);
realTimeNotificationCallbacks.put(participantAddedHandler, PARTICIPANTS_ADDED);
RealTimeNotificationCallback participantRemovedHandler = (ChatEvent payload) -> {
eventHandlerCalled++;
Log.i(TAG, eventHandlerCalled + " messages handled.");
ParticipantsRemovedEvent event = (ParticipantsRemovedEvent) payload;
Log.i(TAG, "Participants removed! ThreadId: " + event.getChatThreadId());
};
chatAsyncClient.addEventHandler(PARTICIPANTS_REMOVED, participantRemovedHandler);
realTimeNotificationCallbacks.put(participantRemovedHandler, PARTICIPANTS_REMOVED);
}
use of com.azure.android.communication.chat.models.ChatMessageEditedEvent in project azure-sdk-for-android by Azure.
the class NotificationUtils method getChatMessageEdited.
private static ChatEvent getChatMessageEdited(String body) {
try {
ChatMessageEditedEvent chatMessageEditedEvent = JACKSON_SERDER.deserialize(body, ChatMessageEditedEvent.class, SerdeEncoding.JSON);
EventAccessorHelper.setChatMessageEditedEvent(chatMessageEditedEvent);
return chatMessageEditedEvent;
} catch (IOException e) {
CLIENT_LOGGER.error(e.getMessage());
return null;
}
}
Aggregations