Created
January 18, 2017 00:16
-
-
Save marinoluck/2e7996836eda64ebf3b0d5adb6304a35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.etermax.crackme.core.actions.connection; | |
import com.etermax.crackme.core.actions.factory.ChatObservablesContainer; | |
import com.etermax.crackme.core.domain.conversation.ConversationXmppService; | |
import com.etermax.crackme.core.domain.message.MessageXmppService; | |
import com.etermax.crackme.core.domain.processor.PersistOnRepositoryNewMessages; | |
import com.etermax.crackme.core.domain.processor.RetrieveConversationWhenMessageIsOrphan; | |
import com.etermax.crackme.core.domain.processor.UpdateConversationFromMessage; | |
import com.etermax.crackme.core.domain.processor.UpdateLastMessageWhenConversationIsCreated; | |
import com.etermax.crackme.core.domain.sync.SyncXmppService; | |
public class Start { | |
private final MessageXmppService messageXmppService; | |
private final ConversationXmppService conversationXmppService; | |
private final ChatObservablesContainer chatObservablesContainer; | |
private final SyncXmppService syncXmppService; | |
private final UpdateConversationFromMessage updateConversationFromMessage; | |
private final UpdateLastMessageWhenConversationIsCreated updateLastMessageWhenConversationIsCreated; | |
private final RetrieveConversationWhenMessageIsOrphan retrieveConversationWhenMessageIsOrphan; | |
private final PersistOnRepositoryNewMessages persistOnRepositoryNewMessages; | |
public Start(ChatObservablesContainer chatObservablesContainer, | |
ConversationXmppService conversationXmppService, | |
MessageXmppService messageXmppService, | |
SyncXmppService syncXmppService, UpdateConversationFromMessage updateConversationFromMessage, UpdateLastMessageWhenConversationIsCreated updateLastMessageWhenConversationIsCreated, RetrieveConversationWhenMessageIsOrphan retrieveConversationWhenMessageIsOrphan, PersistOnRepositoryNewMessages persistOnRepositoryNewMessages) { | |
this.messageXmppService = messageXmppService; | |
this.conversationXmppService = conversationXmppService; | |
this.chatObservablesContainer = chatObservablesContainer; | |
this.syncXmppService = syncXmppService; | |
this.updateConversationFromMessage = updateConversationFromMessage; | |
this.updateLastMessageWhenConversationIsCreated = updateLastMessageWhenConversationIsCreated; | |
this.retrieveConversationWhenMessageIsOrphan = retrieveConversationWhenMessageIsOrphan; | |
this.persistOnRepositoryNewMessages = persistOnRepositoryNewMessages; | |
} | |
public void execute() { | |
startConversationProcessor(); | |
startMessageProcessor(); | |
startSyncProcessor(); | |
} | |
private void startMessageProcessor() { | |
messageXmppService.startMessagesListening(); | |
updateConversationFromMessage.execute(); | |
retrieveConversationWhenMessageIsOrphan.execute(); | |
persistOnRepositoryNewMessages.execute(); | |
} | |
private void startConversationProcessor() { | |
conversationXmppService.startEventsListening(); | |
updateLastMessageWhenConversationIsCreated.execute(); | |
} | |
private void startSyncProcessor() { | |
chatObservablesContainer.setSyncObservable(syncXmppService.startEventsListening()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment