@@ -11,6 +11,7 @@ import {
1111import { useLog } from 'core' ;
1212import { TrainerComponent } from './trainer.component' ;
1313import { useWithRef , getHostBaseUrl } from 'common' ;
14+ import { getPreviousSessionContent } from 'common-app' ;
1415
1516interface Params {
1617 token : string ;
@@ -20,28 +21,26 @@ interface Params {
2021export const TrainerContainer = ( ) => {
2122 const { token, room } = useParams < Params > ( ) ;
2223 const { log, appendToLog, logRef } = useLog ( ) ;
23- const [ socket , setSocket , socketRef ] = useWithRef < SocketIO . Socket > ( null ) ;
24+ const socketDetails = { room : room , trainertoken : token } ;
25+ const [ socket , setSocket , socketRef ] = useWithRef < SocketIO . Socket > ( createSocket ( socketDetails ) ) ;
2426
2527 const [ currentTrainerUrl , setCurrentTrainerUrl ] = React . useState < string > ( '' ) ;
2628 const [ currentStudentUrl , setCurrentStudentUrl ] = React . useState < string > ( '' ) ;
2729
2830 const handleConnection = ( ) => {
29- // Connect to socket
30- const localSocket = createSocket ( {
31- room : room ,
32- trainertoken : token ,
33- } ) ;
34-
35- setSocket ( localSocket ) ;
36-
37- localSocket . on ( SocketOuputMessageLiteral . MESSAGE , msg => {
31+ socket . on ( SocketOuputMessageLiteral . MESSAGE , msg => {
3832 if ( msg . type ) {
3933 const { type, payload } = msg ;
4034
4135 switch ( type ) {
4236 case SocketReceiveMessageTypes . APPEND_TEXT :
4337 appendToLog ( payload ) ;
4438 break ;
39+ case SocketReceiveMessageTypes . TRAINER_GET_FULL_CONTENT :
40+ appendToLog ( payload ) ;
41+ break ;
42+ default :
43+ break ;
4544 }
4645 }
4746 } ) ;
@@ -51,6 +50,7 @@ export const TrainerContainer = () => {
5150 setCurrentTrainerUrl ( `${ getHostBaseUrl ( ) } #${ routes . trainer ( room , token ) } ` ) ;
5251 setCurrentStudentUrl ( `${ getHostBaseUrl ( ) } #${ routes . student ( room ) } ` ) ;
5352 handleConnection ( ) ;
53+ getPreviousSessionContent ( socketRef , SocketEmitMessageTypes . TRAINER_REQUEST_FULL_CONTENT ) ;
5454 } , [ ] ) ;
5555
5656 const appendLineSeparator = ( text : string ) : string =>
0 commit comments