@@ -39,27 +39,48 @@ export const processOuputMessage = (socketInfo: SocketInfo, action: Action) => {
3939 break ;
4040 case OutputMessageTypes . APPEND_TEXT :
4141 handleAppendText ( socketInfo , action . payload ) ;
42+ break ;
4243 case OutputMessageTypes . REPLACE_FULL_TEXT :
4344 handleReplaceFullText ( socketInfo , action . payload ) ;
45+ break ;
4446 case OutputMessageTypes . STUDENT_SEND_FULL_CONTENT :
45- handleStudentSendContent ( socketInfo ) ;
47+ handleSingleStudentSendFullContent ( socketInfo ) ;
48+ break ;
49+ case OutputMessageTypes . TRAINER_SEND_FULL_CONTENT :
50+ handleTrainerSendFullContent ( socketInfo ) ;
51+ break ;
52+ default :
53+ break ;
4654 }
4755} ;
4856
49- const handleStudentSendContent = ( socketInfo : SocketInfo ) => {
57+ const handleSingleStudentSendFullContent = ( socketInfo : SocketInfo ) => {
58+ handleSendFullContent ( socketInfo , responseType . STUDENT_GET_FULL_CONTENT ) ;
59+ }
60+
61+ const handleTrainerSendFullContent = ( socketInfo : SocketInfo ) => {
62+ handleSendFullContent ( socketInfo , responseType . TRAINER_GET_FULL_CONTENT ) ;
63+ }
64+
65+ const handleSendFullContent = ( socketInfo : SocketInfo , responseType : string ) => {
5066 const room = getRoomFromConnectionId ( socketInfo . connectionId ) ;
5167 const content = getRoomContent ( room ) ;
52-
5368 socketInfo . socket . emit ( SocketOuputMessageLiteral . MESSAGE , {
54- type : responseType . STUDENT_GET_FULL_CONTENT ,
69+ type : responseType ,
5570 payload : content ,
5671 } ) ;
5772} ;
5873
74+
75+
76+ // TODO: replace with handleSingleStudentSendFullContent code
77+ // but instead of using socketInfo.socket.emit use
78+ // socketInfo.io.in(room)
5979const handleReplaceFullText = ( socketInfo : SocketInfo , text : string ) => {
6080 const room = getRoomFromConnectionId ( socketInfo . connectionId ) ;
6181 socketInfo . io . in ( room ) . emit ( SocketOuputMessageLiteral . MESSAGE , {
62- type : responseType . REPLACE_FULL_TEXT ,
82+ // TODO: remove from const list REPLACE_FULL_TEXT
83+ type : responseType . REPLACE_FULL_TEXT , //STUDENT_GET_FULL_CONTENT
6384 payload : text ,
6485 } ) ;
6586} ;
0 commit comments