11package com .rtm516 .mcxboxbroadcast .core ;
22
3+ import com .rtm516 .mcxboxbroadcast .core .configs .FriendSyncConfig ;
34import com .rtm516 .mcxboxbroadcast .core .exceptions .SessionCreationException ;
45import com .rtm516 .mcxboxbroadcast .core .exceptions .SessionUpdateException ;
56import com .rtm516 .mcxboxbroadcast .core .models .CreateSessionRequest ;
@@ -30,6 +31,8 @@ public class SessionManager extends SessionManagerCore {
3031 private final ScheduledExecutorService scheduledThreadPool ;
3132 private final Map <String , SubSessionManager > subSessionManagers ;
3233
34+ private FriendSyncConfig friendSyncConfig ;
35+
3336 /**
3437 * Create an instance of SessionManager
3538 *
@@ -64,16 +67,21 @@ public ExpandedSessionInfo sessionInfo() {
6467 /**
6568 * Initialize the session manager with the given session information
6669 *
67- * @param sessionInfo The session information to use
70+ * @param sessionInfo The session information to use
71+ * @param friendSyncConfig The friend sync configuration to use
6872 * @throws SessionCreationException If the session failed to create either because it already exists or some other reason
6973 * @throws SessionUpdateException If the session data couldn't be set due to some issue
7074 */
71- public void init (SessionInfo sessionInfo ) throws SessionCreationException , SessionUpdateException {
75+ public void init (SessionInfo sessionInfo , FriendSyncConfig friendSyncConfig ) throws SessionCreationException , SessionUpdateException {
7276 // Set the internal session information based on the session info
7377 this .sessionInfo = new ExpandedSessionInfo ("" , "" , sessionInfo );
7478
7579 super .init ();
7680
81+ // Set up the auto friend sync
82+ this .friendSyncConfig = friendSyncConfig ;
83+ friendManager ().initAutoFriend (friendSyncConfig );
84+
7785 // Load sub-sessions from cache
7886 List <String > subSessions = new ArrayList <>();
7987 try {
@@ -84,6 +92,7 @@ public void init(SessionInfo sessionInfo) throws SessionCreationException, Sessi
8492 for (String subSession : subSessions ) {
8593 SubSessionManager subSessionManager = new SubSessionManager (subSession , this , Paths .get (cache , subSession ).toString (), logger );
8694 subSessionManager .init ();
95+ subSessionManager .friendManager ().initAutoFriend (friendSyncConfig );
8796 subSessionManagers .put (subSession , subSessionManager );
8897 }
8998 }
@@ -171,6 +180,7 @@ public void addSubSession(String id) {
171180 try {
172181 SubSessionManager subSessionManager = new SubSessionManager (id , this , Paths .get (cache , id ).toString (), logger );
173182 subSessionManager .init ();
183+ subSessionManager .friendManager ().initAutoFriend (friendSyncConfig );
174184 subSessionManagers .put (id , subSessionManager );
175185 } catch (SessionCreationException | SessionUpdateException e ) {
176186 coreLogger .error ("Failed to create sub-session" , e );
0 commit comments