File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,6 +327,15 @@ function emitRefresh(socket) {
327327 socket . emit ( 'refresh' , out ) ;
328328}
329329
330+ function isDuplicatedInSocketQueue ( queue , socket ) {
331+ for ( var i = 0 ; i < queue . length ; i ++ ) {
332+ if ( queue [ i ] && queue [ i ] . id == socket . id ) {
333+ return true ;
334+ }
335+ }
336+ return false ;
337+ }
338+
330339function clearSocketQueue ( queue , socket ) {
331340 for ( var i = 0 ; i < queue . length ; i ++ ) {
332341 if ( ! queue [ i ] || queue [ i ] . id == socket . id ) {
@@ -654,6 +663,8 @@ function connection(socket) {
654663 if ( ! noteId ) {
655664 return failConnection ( 404 , 'note id not found' , socket ) ;
656665 }
666+
667+ if ( isDuplicatedInSocketQueue ( socket , connectionSocketQueue ) ) return ;
657668
658669 // store noteId in this socket session
659670 socket . noteId = noteId ;
@@ -830,6 +841,7 @@ function connection(socket) {
830841
831842 //when a new client disconnect
832843 socket . on ( 'disconnect' , function ( ) {
844+ if ( isDuplicatedInSocketQueue ( socket , disconnectSocketQueue ) ) return ;
833845 disconnectSocketQueue . push ( socket ) ;
834846 disconnect ( socket ) ;
835847 } ) ;
You can’t perform that action at this time.
0 commit comments