Move initialization code to method

This commit is contained in:
Paul Schaub 2019-09-01 02:03:31 +02:00
parent b07d6d541b
commit 3744778155
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 14 additions and 6 deletions

View File

@ -102,12 +102,7 @@ public class ConnectionCenter {
connectionMap.put(account.getId(), connection);
// initialize new connection
RosterStore rosterStore = new RosterStore(rosterRepository);
rosterStore.setAccountId(account.getId());
rosterStore.subscribe();
connection.getRoster().setRosterStore(rosterStore);
messageStore.registerForMercuryConnection(connection);
initializeConnection(connection);
if (account.getEnabled()) {
LOGGER.log(Level.INFO, "Connecting...");
@ -168,6 +163,19 @@ public class ConnectionCenter {
return new MercuryConnection(tcpConnection, accountModel.getId());
}
public void initializeConnection(MercuryConnection connection) {
// Register roster store
RosterStore rosterStore = new RosterStore(rosterRepository);
rosterStore.setAccountId(connection.getAccountId());
rosterStore.subscribe();
connection.getRoster().setRosterStore(rosterStore);
// Register message store
messageStore.registerForMercuryConnection(connection);
//
}
/**
* Set Client State Indication status to active.
*