@@ -179,25 +179,23 @@ private void createSession() throws SessionCreationException, SessionUpdateExcep
179179 XboxTokenInfo tokenInfo = getXboxToken ();
180180 String token = tokenInfo .tokenHeader ();
181181
182- // Update the current session infos XUID
182+ // We only need a websocket for the primary session manager
183183 if (this .sessionInfo != null ) {
184+ // Update the current session XUID
184185 this .sessionInfo .setXuid (tokenInfo .userXUID ());
185- }
186186
187- // Create the RTA websocket connection
188- setupWebsocket (token );
187+ // Create the RTA websocket connection
188+ setupWebsocket (token );
189189
190- // Wait and get the connection ID from the websocket
191- String connectionId ;
192- try {
193- connectionId = waitForConnectionId ().get ();
194- } catch (InterruptedException | ExecutionException e ) {
195- throw new SessionCreationException ("Unable to get connectionId for session: " + e .getMessage ());
196- }
190+ try {
191+ // Wait and get the connection ID from the websocket
192+ String connectionId = waitForConnectionId ().get ();
197193
198- // Update the current session infos connection ID
199- if (this .sessionInfo != null ) {
200- this .sessionInfo .setConnectionId (connectionId );
194+ // Update the current session connection ID
195+ this .sessionInfo .setConnectionId (connectionId );
196+ } catch (InterruptedException | ExecutionException e ) {
197+ throw new SessionCreationException ("Unable to get connectionId for session: " + e .getMessage ());
198+ }
201199 }
202200
203201 // Push the session information to the session directory
@@ -264,9 +262,6 @@ private void createSession() throws SessionCreationException, SessionUpdateExcep
264262 * @throws SessionUpdateException If the update fails
265263 */
266264 protected void updateSessionInternal (String url , Object data ) throws SessionUpdateException {
267- // Make sure the websocket connection is still active
268- checkConnection ();
269-
270265 HttpRequest createSessionRequest ;
271266 try {
272267 createSessionRequest = HttpRequest .newBuilder ()
@@ -297,8 +292,8 @@ protected void updateSessionInternal(String url, Object data) throws SessionUpda
297292 * Check the connection to the websocket and if its closed re-open it and re-create the session
298293 * This should be called before any updates to the session otherwise they might fail
299294 */
300- public void checkConnection () {
301- if (!rtaWebsocket .isOpen ()) {
295+ protected void checkConnection () {
296+ if (this . rtaWebsocket != null && !rtaWebsocket .isOpen ()) {
302297 try {
303298 logger .info ("Connection to websocket lost, re-creating session..." );
304299 createSession ();
0 commit comments