File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,6 @@ import {
56
56
DeleteContextPayload ,
57
57
addComponentToContext
58
58
} from '../../../src/redux/reducers/slice/contextReducer' ;
59
- import Canvas from '../components/main/Canvas' ;
60
59
61
60
// // for websockets
62
61
// // Part - join room and room code functionality
@@ -126,7 +125,8 @@ const RoomsContainer = () => {
126
125
} ) ;
127
126
128
127
socket . on ( 'child data from server' , ( childData : object ) => {
129
- console . log ( 'child data received by users' , childData ) ;
128
+ console . log ( `child data received by socket ${ socket . id } ` , childData ) ;
129
+ console . log ( socket ) ;
130
130
store . dispatch ( addChild ( childData ) ) ;
131
131
} ) ;
132
132
Original file line number Diff line number Diff line change @@ -231,7 +231,9 @@ function Canvas(props: {}): JSX.Element {
231
231
contextParam : contextParam
232
232
} ) ;
233
233
234
- console . log ( 'emit addChildAction event is triggered in canvas' ) ;
234
+ console . log (
235
+ `emit addChildAction event is triggered in canvas from ${ socket . id } `
236
+ ) ;
235
237
}
236
238
} else if ( item . newInstance && item . instanceType === 'Component' ) {
237
239
let hasDiffParent = false ;
Original file line number Diff line number Diff line change @@ -4,12 +4,14 @@ import config from '../../../config';
4
4
let socket = null ;
5
5
6
6
export const initializeSocket = ( ) => {
7
- if ( socket ) socket . connect ( ) ;
8
- if ( ! socket ) {
9
- socket = io ( config . API_BASE_URL , { transports : [ 'websocket' ] } ) ;
10
- console . log ( 'A user connected' ) ;
11
- console . log ( 'socket:' , socket ) ;
12
- }
7
+ socket = io ( config . API_BASE_URL , {
8
+ transports : [ 'websocket' ] ,
9
+ // will force new socket connection if re-joining to prevent double emits
10
+ forceNew : true
11
+ } ) ;
12
+ console . log ( 'A user connected' ) ;
13
+ console . log ( 'socket:' , socket ) ;
14
+ // }
13
15
} ;
14
16
15
17
// export socket to ensure a single socket instance across the entire app
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ io.on('connection', (client) => {
182
182
if ( roomCode ) {
183
183
//server send the data to everyone in the room
184
184
client . to ( roomCode ) . emit ( 'child data from server' , childData ) ;
185
+ console . log ( `client id: ${ client . id } sending from server ${ childData } ` ) ;
185
186
}
186
187
} ) ;
187
188
You can’t perform that action at this time.
0 commit comments