summaryrefslogtreecommitdiff
path: root/src/main/overleafSocket.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/overleafSocket.ts')
-rw-r--r--src/main/overleafSocket.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/overleafSocket.ts b/src/main/overleafSocket.ts
index f825c4c..52ac20f 100644
--- a/src/main/overleafSocket.ts
+++ b/src/main/overleafSocket.ts
@@ -92,6 +92,10 @@ export class OverleafSocket extends EventEmitter {
return this._projectData
}
+ get publicId(): string | null {
+ return this._projectData?.publicId || null
+ }
+
private setState(s: ConnectionState) {
this._state = s
this.emit('connectionState', s)
@@ -270,6 +274,20 @@ export class OverleafSocket extends EventEmitter {
this.ws?.send(encodeEvent('applyOtUpdate', [docId, { doc: docId, op: ops, v: version, hash, lastV: version }]))
}
+ /** Get list of connected users with their cursor positions */
+ async getConnectedUsers(): Promise<unknown[]> {
+ const result = await this.emitWithAck('clientTracking.getConnectedUsers', []) as unknown[]
+ // result format: [error, usersArray]
+ const err = result[0]
+ if (err) throw new Error(`getConnectedUsers failed: ${JSON.stringify(err)}`)
+ return (result[1] as unknown[]) || []
+ }
+
+ /** Send our cursor position */
+ updateCursorPosition(docId: string, row: number, column: number): void {
+ this.ws?.send(encodeEvent('clientTracking.updatePosition', [{ row, column, doc_id: docId }]))
+ }
+
disconnect() {
this.shouldReconnect = false
this.stopHeartbeat()