This commit is contained in:
呈祥
2026-01-07 00:10:46 +08:00
parent 3a671f94f7
commit aa123e5cf2
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
// 客户端实现
import { SimpleTextOperation as TextOperation } from "./op";
import { Noop, SimpleTextOperation as TextOperation } from "./op";
import { getDemoServerInstance } from "./server";
// 直接获取server实例,这里省略了网络过程
@@ -94,7 +94,7 @@ export class Client {
this.enableSync = enabled;
// 重新启用同步,继续发送本地操作,发送一个空操作,确保服务端向我们推送最新操作
if (enabled) {
// this.buffer.push(new Noop());
this.buffer.push(new Noop());
this.sendOperationIfNeed();
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ class Server {
// 每当从客户端接收到操作时调用此方法
receiveOperation(client: Client, revision: number, operation: TextOperation) {
console.log("server", "received operation", revision, operation);
console.log("server", "received operation from", client.name, revision, operation);
if (revision < 0 || this.operations.length < revision) {
throw new Error("operation revision not in history");