use of com.azure.android.communication.chat.models.RealTimeNotificationCallback 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);
}
Aggregations