2022-10-26 00:50:07 +08:00
|
|
|
import { SysCallMapping } from "../../plugos/system.ts";
|
|
|
|
import type { Editor } from "../editor.tsx";
|
|
|
|
|
|
|
|
export function collabSyscalls(editor: Editor): SysCallMapping {
|
|
|
|
return {
|
|
|
|
"collab.start": (
|
|
|
|
_ctx,
|
|
|
|
serverUrl: string,
|
|
|
|
token: string,
|
|
|
|
username: string,
|
|
|
|
) => {
|
|
|
|
editor.startCollab(serverUrl, token, username);
|
|
|
|
},
|
|
|
|
"collab.stop": (
|
|
|
|
_ctx,
|
|
|
|
) => {
|
2023-05-29 23:05:20 +08:00
|
|
|
editor.stopCollab();
|
|
|
|
},
|
|
|
|
"collab.ping": async (
|
|
|
|
_ctx,
|
|
|
|
clientId: string,
|
|
|
|
currentPage: string,
|
|
|
|
) => {
|
|
|
|
const resp = await editor.remoteSpacePrimitives.authenticatedFetch(
|
|
|
|
editor.remoteSpacePrimitives.url,
|
|
|
|
{
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
operation: "ping",
|
|
|
|
clientId,
|
|
|
|
page: currentPage,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return resp.json();
|
2022-10-26 00:50:07 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|