mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 11:37:02 -04:00
refactor: reimplement realtime-communication
This commit refactors a lot of things that are not easy to separate. It replaces the binary protocol of y-protocols with json. It introduces event based message processing. It implements our own code mirror plugins for synchronisation of content and remote cursors Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
67cf1432b2
commit
3a06f84af1
110 changed files with 3920 additions and 2201 deletions
36
commons/src/message-transporters/message.ts
Normal file
36
commons/src/message-transporters/message.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { RealtimeUser, RemoteCursor } from './realtime-user.js'
|
||||
|
||||
export enum MessageType {
|
||||
NOTE_CONTENT_STATE_REQUEST = 'NOTE_CONTENT_STATE_REQUEST',
|
||||
NOTE_CONTENT_UPDATE = 'NOTE_CONTENT_UPDATE',
|
||||
PING = 'PING',
|
||||
PONG = 'PONG',
|
||||
METADATA_UPDATED = 'METADATA_UPDATED',
|
||||
DOCUMENT_DELETED = 'DOCUMENT_DELETED',
|
||||
SERVER_VERSION_UPDATED = 'SERVER_VERSION_UPDATED',
|
||||
REALTIME_USER_STATE_SET = 'REALTIME_USER_STATE_SET',
|
||||
REALTIME_USER_SINGLE_UPDATE = 'REALTIME_USER_SINGLE_UPDATE',
|
||||
REALTIME_USER_STATE_REQUEST = 'REALTIME_USER_STATE_REQUEST',
|
||||
READY = 'READY'
|
||||
}
|
||||
|
||||
export interface MessagePayloads {
|
||||
[MessageType.NOTE_CONTENT_STATE_REQUEST]: number[]
|
||||
[MessageType.NOTE_CONTENT_UPDATE]: number[]
|
||||
[MessageType.REALTIME_USER_STATE_SET]: RealtimeUser[]
|
||||
[MessageType.REALTIME_USER_SINGLE_UPDATE]: RemoteCursor
|
||||
}
|
||||
|
||||
export type Message<T extends MessageType> = T extends keyof MessagePayloads
|
||||
? {
|
||||
type: T
|
||||
payload: MessagePayloads[T]
|
||||
}
|
||||
: {
|
||||
type: T
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue