5757public class SessionRestController {
5858
5959 @ Autowired
60- private SessionManager sessionManager ;
60+ private SessionManagerProvider sessionManagerProvider ;
6161
6262 @ Autowired
6363 private SessionStorage sessionStorage ;
6464
65+ @ Autowired
66+ private Utils utils ;
67+
6568 @ Autowired
6669 private ComposedRecordingService recordingService ;
6770
@@ -125,11 +128,11 @@ public ResponseEntity<JSONObject> getSessionId(@RequestBody(required = false) Ma
125128 }
126129 sessionId = customSessionId ;
127130 } else {
128- sessionId = sessionManager .generateRandomChain ();
131+ sessionId = utils .generateRandomChain ();
129132 this .sessionStorage .putTokenObject (sessionId , new ConcurrentHashMap <>());
130133 }
131134
132- sessionManager .storeSessionId (sessionId , sessionProperties );
135+ sessionStorage .storeSessionId (sessionId , sessionProperties );
133136 JSONObject responseJson = new JSONObject ();
134137 responseJson .put ("id" , sessionId );
135138
@@ -140,7 +143,7 @@ public ResponseEntity<JSONObject> getSessionId(@RequestBody(required = false) Ma
140143 @ RequestMapping (value = "/sessions/{sessionId}" , method = RequestMethod .GET )
141144 public ResponseEntity <JSONObject > getSession (@ PathVariable ("sessionId" ) String sessionId ,
142145 @ RequestParam (value = "webRtcStats" , defaultValue = "false" , required = false ) boolean webRtcStats ) {
143- Session session = this .sessionManager .getSession (sessionId );
146+ Session session = this .sessionStorage .getSession (sessionId );
144147 if (session != null ) {
145148 JSONObject response = (webRtcStats == true ) ? session .withStatsToJSON () : session .toJSON ();
146149 response .put ("recording" , this .recordingService .sessionIsBeingRecorded (sessionId ));
@@ -154,7 +157,7 @@ public ResponseEntity<JSONObject> getSession(@PathVariable("sessionId") String s
154157 @ RequestMapping (value = "/sessions" , method = RequestMethod .GET )
155158 public ResponseEntity <JSONObject > listSessions (
156159 @ RequestParam (value = "webRtcStats" , defaultValue = "false" , required = false ) boolean webRtcStats ) {
157- Collection <Session > sessions = this .sessionManager .getSessionObjects ();
160+ Collection <Session > sessions = this .sessionStorage .getSessionObjects ();
158161 JSONObject json = new JSONObject ();
159162 JSONArray jsonArray = new JSONArray ();
160163 sessions .forEach (s -> {
@@ -169,9 +172,9 @@ public ResponseEntity<JSONObject> listSessions(
169172
170173 @ RequestMapping (value = "/sessions/{sessionId}" , method = RequestMethod .DELETE )
171174 public ResponseEntity <JSONObject > closeSession (@ PathVariable ("sessionId" ) String sessionId ) {
172- Session session = this .sessionManager .getSession (sessionId );
175+ Session session = this .sessionStorage .getSession (sessionId );
173176 if (session != null ) {
174- this .sessionManager .closeSession (sessionId , "sessionClosedByServer" );
177+ this .sessionManagerProvider . get ( sessionId ) .closeSession (sessionId , "sessionClosedByServer" );
175178 return new ResponseEntity <>(HttpStatus .NO_CONTENT );
176179 } else {
177180 return new ResponseEntity <>(HttpStatus .NOT_FOUND );
@@ -181,11 +184,11 @@ public ResponseEntity<JSONObject> closeSession(@PathVariable("sessionId") String
181184 @ RequestMapping (value = "/sessions/{sessionId}/connection/{connectionId}" , method = RequestMethod .DELETE )
182185 public ResponseEntity <JSONObject > disconnectParticipant (@ PathVariable ("sessionId" ) String sessionId ,
183186 @ PathVariable ("connectionId" ) String participantPublicId ) {
184- Session session = this .sessionManager .getSession (sessionId );
187+ Session session = this .sessionStorage .getSession (sessionId );
185188 if (session != null ) {
186189 Participant participant = session .getParticipantByPublicId (participantPublicId );
187190 if (participant != null ) {
188- this .sessionManager .evictParticipant (participant , null , null , "forceDisconnectByServer" );
191+ this .sessionManagerProvider . get ( sessionId ) .evictParticipant (participant , null , null , "forceDisconnectByServer" );
189192 return new ResponseEntity <>(HttpStatus .NO_CONTENT );
190193 } else {
191194 return new ResponseEntity <>(HttpStatus .NOT_FOUND );
@@ -198,9 +201,9 @@ public ResponseEntity<JSONObject> disconnectParticipant(@PathVariable("sessionId
198201 @ RequestMapping (value = "/sessions/{sessionId}/stream/{streamId}" , method = RequestMethod .DELETE )
199202 public ResponseEntity <JSONObject > unpublishStream (@ PathVariable ("sessionId" ) String sessionId ,
200203 @ PathVariable ("streamId" ) String streamId ) {
201- Session session = this .sessionManager .getSession (sessionId );
204+ Session session = this .sessionStorage .getSession (sessionId );
202205 if (session != null ) {
203- if (this .sessionManager .unpublishStream (session , streamId , null , null , "forceUnpublishByServer" )) {
206+ if (this .sessionManagerProvider . get ( sessionId ) .unpublishStream (session , streamId , null , null , "forceUnpublishByServer" )) {
204207 return new ResponseEntity <>(HttpStatus .NO_CONTENT );
205208 } else {
206209 return new ResponseEntity <>(HttpStatus .NOT_FOUND );
@@ -236,7 +239,7 @@ public ResponseEntity<JSONObject> newToken(@RequestBody Map<?, ?> params) {
236239
237240 metadata = (metadata != null ) ? metadata : "" ;
238241
239- String token = sessionManager .newToken (sessionId , role , metadata );
242+ String token = sessionStorage .newToken (sessionId , role , metadata );
240243 JSONObject responseJson = new JSONObject ();
241244 responseJson .put ("id" , token );
242245 responseJson .put ("session" , sessionId );
@@ -271,7 +274,7 @@ public ResponseEntity<JSONObject> startRecordingSession(@RequestBody Map<?, ?> p
271274 return new ResponseEntity <>(HttpStatus .NOT_IMPLEMENTED );
272275 }
273276
274- Session session = sessionManager .getSession (sessionId );
277+ Session session = sessionStorage .getSession (sessionId );
275278
276279 if (session == null ) {
277280 // Session does not exist
@@ -327,11 +330,11 @@ public ResponseEntity<JSONObject> stopRecordingSession(@PathVariable("recordingI
327330 return new ResponseEntity <>(HttpStatus .CONFLICT );
328331 }
329332
330- Session session = sessionManager .getSession (recording .getSessionId ());
333+ Session session = sessionStorage .getSession (recording .getSessionId ());
331334
332335 Recording stoppedRecording = this .recordingService .stopRecording (session );
333336
334- sessionManager .evictParticipant (
337+ sessionManagerProvider . get ( session . getSessionId ()) .evictParticipant (
335338 session .getParticipantByPublicId (ProtocolElements .RECORDER_PARTICIPANT_PUBLICID ), null , null ,
336339 "EVICT_RECORDER" );
337340
0 commit comments