File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -272,16 +272,24 @@ function isReady () {
272272}
273273
274274function extractNoteIdFromSocket ( socket ) {
275- if ( ! socket || ! socket . handshake || ! socket . handshake . headers ) {
275+ if ( ! socket || ! socket . handshake ) {
276276 return false
277277 }
278- var referer = socket . handshake . headers . referer
279- if ( ! referer ) {
278+ if ( socket . handshake . query && socket . handshake . query . noteId ) {
279+ return socket . handshake . query . noteId
280+ } else if ( socket . handshake . headers ) {
281+ // this part is only for backward compatibility only; current code
282+ // should be using noteId query parameter instead.
283+ var referer = socket . handshake . headers . referer
284+ if ( ! referer ) {
285+ return false
286+ }
287+ var hostUrl = url . parse ( referer )
288+ var noteId = config . urlpath ? hostUrl . pathname . slice ( config . urlpath . length + 1 , hostUrl . pathname . length ) . split ( '/' ) [ 1 ] : hostUrl . pathname . split ( '/' ) [ 1 ]
289+ return noteId
290+ } else {
280291 return false
281292 }
282- var hostUrl = url . parse ( referer )
283- var noteId = config . urlpath ? hostUrl . pathname . slice ( config . urlpath . length + 1 , hostUrl . pathname . length ) . split ( '/' ) [ 1 ] : hostUrl . pathname . split ( '/' ) [ 1 ]
284- return noteId
285293}
286294
287295function parseNoteIdFromSocket ( socket , callback ) {
Original file line number Diff line number Diff line change @@ -1762,6 +1762,9 @@ window.havePermission = havePermission
17621762var io = require ( 'socket.io-client' )
17631763var socket = io . connect ( {
17641764 path : urlpath ? '/' + urlpath + '/socket.io/' : '' ,
1765+ query : {
1766+ noteId : noteid
1767+ } ,
17651768 timeout : 5000 , // 5 secs to timeout,
17661769 reconnectionAttempts : 20 // retry 20 times on connect failed
17671770} )
You can’t perform that action at this time.
0 commit comments