mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #2890 from overleaf/jpa-socket-io-secondary-id
[misc] socket.io: use a secondary publicId for public facing usages GitOrigin-RevId: f472c90ce0706aaf409e63c4199e71899b1aefa3
This commit is contained in:
parent
6c614a6adc
commit
9eaa1f9677
3 changed files with 8 additions and 5 deletions
|
@ -177,7 +177,8 @@ export default (ConnectionManager = (function() {
|
||||||
// from the server, either "connectionAccepted" or
|
// from the server, either "connectionAccepted" or
|
||||||
// "connectionRejected".
|
// "connectionRejected".
|
||||||
|
|
||||||
this.ide.socket.on('connectionAccepted', message => {
|
this.ide.socket.on('connectionAccepted', (_, publicId) => {
|
||||||
|
this.ide.socket.publicId = publicId || this.ide.socket.socket.sessionid
|
||||||
// state should be 'authenticating'...
|
// state should be 'authenticating'...
|
||||||
sl_console.log('[socket.io connectionAccepted] allowed to connect')
|
sl_console.log('[socket.io connectionAccepted] allowed to connect')
|
||||||
this.connected = true
|
this.connected = true
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
import EventEmitter from '../../utils/EventEmitter'
|
import EventEmitter from '../../utils/EventEmitter'
|
||||||
import ShareJs from 'libs/sharejs'
|
import ShareJs from 'libs/sharejs'
|
||||||
|
|
||||||
let ShareJsDoc
|
let ShareJsDoc
|
||||||
const SINGLE_USER_FLUSH_DELAY = 1000 // ms
|
const SINGLE_USER_FLUSH_DELAY = 1000 // ms
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ export default (ShareJsDoc = (function() {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
state: 'ok',
|
state: 'ok',
|
||||||
id: this.socket.socket.sessionid
|
id: this.socket.publicId
|
||||||
}
|
}
|
||||||
|
|
||||||
this._doc = new ShareJs.Doc(this.connection, this.doc_id, {
|
this._doc = new ShareJs.Doc(this.connection, this.doc_id, {
|
||||||
|
@ -257,7 +258,7 @@ export default (ShareJsDoc = (function() {
|
||||||
updateConnectionState(state) {
|
updateConnectionState(state) {
|
||||||
sl_console.log(`[updateConnectionState] Setting state to ${state}`)
|
sl_console.log(`[updateConnectionState] Setting state to ${state}`)
|
||||||
this.connection.state = state
|
this.connection.state = state
|
||||||
this.connection.id = this.socket.socket.sessionid
|
this.connection.id = this.socket.publicId
|
||||||
this._doc.autoOpen = false
|
this._doc.autoOpen = false
|
||||||
this._doc._connectionStateChanged(state)
|
this._doc._connectionStateChanged(state)
|
||||||
return (this.lastAcked = null) // reset the last ack time when connection changes
|
return (this.lastAcked = null) // reset the last ack time when connection changes
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
import ColorManager from '../colors/ColorManager'
|
import ColorManager from '../colors/ColorManager'
|
||||||
import 'crypto-js/md5'
|
import 'crypto-js/md5'
|
||||||
import './controllers/OnlineUsersController'
|
import './controllers/OnlineUsersController'
|
||||||
|
|
||||||
let OnlineUsersManager
|
let OnlineUsersManager
|
||||||
|
|
||||||
export default (OnlineUsersManager = (function() {
|
export default (OnlineUsersManager = (function() {
|
||||||
|
@ -42,7 +43,7 @@ export default (OnlineUsersManager = (function() {
|
||||||
(error, connectedUsers) => {
|
(error, connectedUsers) => {
|
||||||
this.$scope.onlineUsers = {}
|
this.$scope.onlineUsers = {}
|
||||||
for (let user of Array.from(connectedUsers || [])) {
|
for (let user of Array.from(connectedUsers || [])) {
|
||||||
if (user.client_id === this.ide.socket.socket.sessionid) {
|
if (user.client_id === this.ide.socket.publicId) {
|
||||||
// Don't store myself
|
// Don't store myself
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -66,7 +67,7 @@ export default (OnlineUsersManager = (function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.ide.socket.on('clientTracking.clientUpdated', client => {
|
this.ide.socket.on('clientTracking.clientUpdated', client => {
|
||||||
if (client.id !== this.ide.socket.socket.sessionid) {
|
if (client.id !== this.ide.socket.publicId) {
|
||||||
// Check it's not me!
|
// Check it's not me!
|
||||||
return this.$scope.$apply(() => {
|
return this.$scope.$apply(() => {
|
||||||
this.$scope.onlineUsers[client.id] = client
|
this.$scope.onlineUsers[client.id] = client
|
||||||
|
|
Loading…
Reference in a new issue